ahmed-shariff / org-roam-ql

Query language for org-roam
GNU General Public License v3.0
88 stars 5 forks source link

How to write an "org-roam-ql" function that could produce an output in an org-roam file? #1

Closed khaledmust closed 1 year ago

khaledmust commented 1 year ago

I tried hacking my way through and wrote the following: (org-roam-ql-nodes '([:select [node-id] :from tags :where (= tag \"resources\")])) which (in mind) is supposed to search the org-roam db for all nodes with the tags "resources" and displays only it's ID, but I get nothing.

I tried this one: (org-roam-ql-nodes '(tags "resources")) and indeed it produced an output, but it's not formatted.

ahmed-shariff commented 1 year ago

Hey,

org-roam-ql-nodes only returns the result of a query in the form of a list of org-roam-nodes. If you want it displayed in a org-roam-mode buffer, you would want to use org-roam-ql-search.

As for the query itself, you don't have to escape the quotes; try this:

(org-roam-ql-nodes '([:select [node-id] :from tags :where (= tag "resources")]))

Re the output of org-roam-ql-nodes I am not sure what you mean by formatted?

khaledmust commented 1 year ago

Thank you @ahmed-shariff for your reply, I really appreciate it.

I tried (org-roam-ql-nodes '([:select [node-id] :from tags :where (= tag "resources")])) and it works, also not formatted, what I expected the output would be something like the Dynamic Block of Org-ql.

This is a screenshot of the output that is produced when executing the function: image

ahmed-shariff commented 1 year ago

Ah I see, unfortunately I haven't gotten around to implementing the dynamic blocks yet. Right now you may have to have a source block with the call to org-roam-ql-nodes that generates a table.

khaledmust commented 1 year ago

Thank you @ahmed-shariff, I am looking forward to the development of this package.

And I will surely adjust my workflow with the current state of the package.

ahmed-shariff commented 1 year ago

Welp, turned out it was much easier than I thought. Try the latest commit and follow this: https://github.com/ahmed-shariff/org-roam-ql#org-dynamic-block

khaledmust commented 1 year ago

Thank you so much, this is amazing. It worked.

But I had some issue, the package is loaded as since I invoke C-h f I find the org-roam-ql-ql-buffer-from-roam-buffer function, but when I evaluate the dynamic block it states that the Symbol's function definition is void.

So I have to evaluate org-roam-ql-ql.el file and it worked.

Don't know why the function is not being loaded.

And again thank you so much.

khaledmust commented 1 year ago

I add the org-roam-ql-ql.el to the load path, and now it's working.

ahmed-shariff commented 1 year ago

Glad to know it helped. Closing the issue for now.