How to query todo without subtodos?

We can, by using rules:

#+BEGIN_QUERY
{
 :query [:find (pull ?block [* ])
 :in $ ?current-page %
 :where
   [?page :block/name ?current-page]  ; in current page
   [?block :block/page ?page]         ; any blocks
   [?block :block/marker ?marker]     ; that have marker
   [(contains? #{"TODO"} ?marker)]    ; TODO
   (not                               ; but don't have
     (descendant ?d ?block)           ; any descendant
     [?d :block/marker ?dmarker]      ; with own marker
     [(contains? #{"TODO"} ?dmarker)] ; TODO
   )
 ]
 :inputs [
   :current-page
   [
     [
       [descendant ?d ?b]
       [?d :block/parent ?b]
     ]
     [
       [descendant ?d ?b]
       [?d :block/parent ?parent]
       (descendant ?parent ?b)
     ]
   ]
 ]
}
#+END_QUERY
1 Like