Query: ignore child blocks

Hi, is there a way to ignore/hide child blocks, so instead of this:

I’d get something like this:

This if from a bit modified default Now query:

{:title "🔨 NOW"
    :query [:find (pull ?h [*])
            :in $ ?start ?today
            [?h :block/marker ?marker]
            [(contains? #{"NOW" "DOING"} ?marker)]
            [?h :block/page ?p]
            [?p :block/journal? true]
            [?p :block/journal-day ?d]
            [(>= ?d ?start)]
            [(<= ?d ?today)]]
    :inputs [:14d :today]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed? false}

:remove-block-children doesn’t do it sadly.

1 Like

There’s a result-transform to collapse all results.

:result-transform (fn [r] (map (fn [m] (assoc m :block/collapsed? true)) r))

Sadly that’s the only way I know.
Though I wonder if the bonus task wouldn’t just show up separately already?
It is after all meeting the criteria and should be shown individually as well.

:remove-block-children is confusing and I’m not sure what it is suppose to do, and also the default is true. :woman_shrugging:t4: See also:

1 Like

Thank you, that helps.

It doesn’t, maybe child blocks are ignored by default to avoid duplicates?

I’ll create a Feature Request asking for :remove-block-children to be expanded to situations like this, as I also think there is no way to do it currently

Accidental discovery, this is exactly what :remove-block-children does :joy:


With :remove-block-children? false

Edit: made a task for myself to add some clarification to the official documentation for this. The current description doesn’t quite capture this behavior :sweat_smile:

Edit: made the pull request: Added extra heading to better explain property remove-block-children by Siferiax · Pull Request #103 · logseq/docs · GitHub

Cheers, nice investigation. It seems like a fairly niche use for non-default value. Still now I need to update my second thread hehe.

1 Like

Hi @Siferiax , thanks for the query, useful as always :slight_smile: Small thing - I’m wondering if it’s possible to make the query be applied only to blocks that have any children? So,
any (1+) children → collapsed by default
no children → left as is

Yes, check out this topic:

1 Like