Hello, everyone. I’m currently using Org Roam for storing articles that I want to publish in my blog.
Every article is stored using the following format (see two examples below)
:PROPERTIES:
:ID: c0f2f094-f412-4451-9765-3aa06f7c0db4
:STATUS: Completed
:END:
#+TITLE: Export Org Mode file to PDF using LaTeX
:PROPERTIES:
:ID: c5fa12c9-10b5-419b-8adf-1669365ff266
:STATUS: Published
:END:
#+TITLE: Table formulas in Org Mode
As you can see above, each article has a STATUS property.
What I’m trying to accomplish is to list all the articles whose STATUS is Published.
Current workaround
I have managed to do this using dolist. However, I don’t find this approach efficient because I have to load all the nodes in memory and, in addition to that, I need to iterate through all nodes linearly. I’m mentioning this so that people don’t suggest me doing this.
Instead, I want to directly query the database since that way we can take advantage of the algorithms that are implemented at the database level instead of using dolist (linear search).
(org-roam-db-query
[:select title
:from nodes
:where <<there exists a property with name "STATUS" and value equal to "Completed"])
The question
Is it possible to query properties at the database level?
Just to show there is a possibility; at least this below works on my end.
I am hoping that there should be a better way, to specify a single property in the vector. I need to leave it to someone with SQL expertise.
@jonathan , org-ql might be a good idea. Org-roam cache database keeps file/heading properties in tables such as nodes in the column named properties. You can see this by looking at the variable org-roam-db--table-schemata.
For what it’s worth, I left that running and walked away, came back hours later and it had returned at some point, with many results, my buffer size had grown to 1.8M.