Grouping in Queries

Hey!
Sorry for reviving this old thread. I have not learned anything about Datascript yet (it’s on my to-do list!) but I’d like to be able to use Logseq productively before finding time for learning…
What should be added to @Hulk’s answer to restrict the grouping to pages that have a specific property?

For example, I typically create TODOs in the journal page, but tagged with the page that it is relevant to:

Nov 2, 2021

  • [[Project 1]]
    • TODO Do this
    • TODO Do that [[Dev]] [[Python]]
  • TODO [[Project 2]] Do this also

Nov 1, 2021

  • TODO [[Project 1]] I should do that
  • [[Project 2]]
    • Problem A
      • TODO I should do this
    • Problem B
      • TODO find a solution

The pages [[Project 1]] and [[Project 2]] have the property “type”:“project”, which [[Dev]] and [[Python]] don’t have.
The standard query {{query (task todo)}} would list all TODOs grouped by journal page.
It’s not very clear to me what Hulk’s proposal is grouping by… But what I would love to have would look something like this:

[[Project 1]]

  • Nov 2, 2021 > Project 1
    • TODO Do this
    • TODO Do that [[Dev]] [[Python]]
  • Nov 1, 2021
    • TODO [[Project 1]] I should do that

[[Project 2]]

  • Nov 2, 2021
    • TODO [[Project 2]] Do this also
  • Nov 1, 2021 > Project 2 > Problem A
    • TODO I should do this
  • Nov 1, 2021 > Project 2 > Problem B
    • TODO find a solution

I’m not sure whether this makes sense, I guess I’ll adapt it when using it, but a little help to get started would greatly help :smiley: Thanks in advance!

3 Likes