This query returns zero results. The way I understand how this query works is:
The combination of :inputs [:current-page] and :in $ ?current-page binds the variable ?current-page to whatever :current-page is; I presume it’s the current page.
[?b :block/page ?p] constraints ?p to be a page on which blocks in the query (represented by ?b) will be found
[?p :block/name ?current-page] constraints ?p to be the current page, which in combination with the previous line, should constrain ?b to be only blocks that can be found on this page.
[?b :block/parent ?parent] constraints a new variable, ?parent, to be a parent of blocks represented by ?b
[?parent :block/content "Members"] constrains ?parent to be blocks that have the content “Members”. In combination with the previous constraint, this should mean that there is only one: the block containing the content “Members” on this page.
Since ?b is constrained to blocks on ?p, ?p is constrained to be this page, ?parent is constrained to be the “Members” block on this page, and the parent of ?b is constrained to be the “Members” block on this page, then I would expect the output to be the three child blocks under the “Members” block. Where have I gone wrong in understanding how this query works?
I use your query, but it just works well when queries test2 which not include block-id data. So I guess when run [?parent :block/content "Members"], the both sides of equation are not same. IDK whether it’s feature or bug, even more how to solve it, last night I take a lot of time to find out some idea but nothing I get.
Now I just combine these blocks with another parent block, like following, cause IDK how to avoid logseq adding data in these blocks, just keep the original😂:
maybe i can use this thread to ask my specific question with a similar topic.
Somewhere in my logseq i write blocks like this. It could be in journal pages or on pages, this shoudn’t matter for the query.
# [[topic1]]
- TODO make this
- TODO make that
- DOING dont forget this and that
# [[otherthings2]]
- TODO make this
- TODO make that
- DOING dont forget this and that
Now i would like to query any TODOs and DOINGs that are parent of a block with pagelink “topic1”.
The above query finds nothing.
If i remove [?b :block/refs ?p] it finds everything with TODO even [[otherthings2]], even though I specified [?p :block/name "topic1"].
#+BEGIN_QUERY
{:title [:h3 "Todo by parent block"]
:query [:find (pull ?b [*])
:where
[?t :block/name "topic1"] ;name is always lower-case
[?b :block/refs ?t] ;get the block that references the page
[?bl :block/parent ?b] ;get the child block
[?bl :block/marker ?marker] ;get the marker
[(= "TODO" ?marker)] ;marker must be TODO
]
:table-view? false ;hides part of query, change to nil to view.
}
#+END_QUERY