FInd nested TODOs

If you indent the query in it, you can run it based on it’s parent block as input.
So for example:

- parent block title
   - meeting notes
     - stuff
   - query

Or make meeting notes the parent, whatever you prefer.
You can then use this as the query:

#+BEGIN_QUERY
{:title ["Query by page & alias"]
 :query [:find (pull ?b [*])
   :in $ ?parent %
   :where
     [?b :block/marker "TODO"]
     (check-parent ?parent ?b)
 ]
 :rules [
   [(check-parent ?parent ?b)
     [?b :block/parent ?parent]
   ]
   [(check-parent ?parent ?b)
     [?b :block/parent ?t]
     (check-parent ?parent ?t)
   ]
 ]
 :inputs [:parent-block]
}
#+END_QUERY

Disclaimer: I did not test this. I wrote it all on my phone by memory.

4 Likes