I have a query where I can return either the child block (child block, page) or the parent block (parent block, page, and properties). What I can’t figure out is how/if I can return these results together (child block, parent block, page and properties). These blocks span various pages. There are duplicate parent block “contents”, e.g. “@Example2020” appearing twice in the example below.
Query to return the child block:
#+BEGIN_QUERY
{:query [:find (pull ?child [*])
:where
[?child :block/ref-pages ?page]
[?page :block/name "tldr"]
[?child :block/parent ?parent]
[?parent :block/properties ?props]
[(get ?props :project) ?proj]
[(= ?proj "research notes")]
]
:remove-child-block? false
}
#+END_QUERY
Result:
and
To return the parent block:
#+BEGIN_QUERY
{:query [:find (pull ?parent [*])
:where
[?child :block/ref-pages ?page]
[?page :block/name "tldr"]
[?child :block/parent ?parent]
[?parent :block/properties ?props]
[(get ?props :project) ?proj]
[(= ?proj "research notes")]
]
:remove-child-block? false
}
#+END_QUERY
Result:
The desired result would look like:
I tried this strategy I learned from the max-datomic tutorial:
?child [* {:block/parent
[* {:block/properties [*]}]
}
]
along with some variations, but couldn’t get it to work. Here is content you can use for a minimal working example:
- @Example2020
purpose:: this is an example
topic:: query
keywords:: test1, test2
links:: [google url sample](https://google.com)
project:: research notes
- #TLDR this is a summary of all the notes i'd take below. it is always the first block under the propertiers. but the text can be a few paragraphs, so i'd like to avoid making it a property. it doesn't really make sense to have a summary as a property anyway.
- Notes
- more notes
- notes notes notes
- notes
- notes are fun
- @Example2020
purpose:: this is an example
topic:: query
keywords:: test1, test2
links:: [google url sample](https://google.com)
project:: research notes
- #TLDR more summary
- @Different1989
purpose:: this is an example
topic:: query
keywords:: test1, test2
links:: [google url sample](https://google.com)
project:: research notes
- #TLDR we are writing a summary