Query children blocks of a specific block?

I can’t find a way to select child blocks of another one. I try to use this query:

#+BEGIN_QUERY
{:title "Foo block children"
 :query [:find (pull ?d [*])
         :where
         [?block :block/uuid "66102291-e5bf-485b-996c-2bb1a3311c02"]
         [?d :block/parent ?block]]
}
#+END_QUERY

What I do wrong?

Apparently :block/uuid is not a proper string.

  • Try replacing this:
    [?block :block/uuid "66102291-e5bf-485b-996c-2bb1a3311c02"]
    
  • with this:
    [?block :block/uuid ?uuid]
    [(str ?uuid) ?str]
    [(= ?str "66102291-e5bf-485b-996c-2bb1a3311c02")]
    
1 Like

Thank you, it worked! So my final query is like this:

#+BEGIN_QUERY
{:title [:b "Foo block children"]
 :query [:find (pull ?d [*])
         :in $ ?parent-block-uuid
         :where
         [?block :block/uuid ?uuid]
         [(str ?uuid) ?str]
         [(= ?str ?parent-block-uuid)]
         [?d :block/parent ?block]]
  :inputs ["66102291-e5bf-485b-996c-2bb1a3311c02"]
}
#+END_QUERY

As for :block/uuid it was chatGPT who recommended it LOL