Hello to anyone with a bit of spare time and knowledge.
I’ve been writing advanced queries for quite a while now in Logseq, but I really cannot understand how to something pretty basic.
Problem: I am trying to write a query (specifically for config.edn :default-queries {}) to show me queries that:
• bullet contains markers TODO or NOW
OR
• scheduled today or has deadline today
I am very confused because I am getting errors, although my logic seems correct.
Attempt 1:
#+BEGIN_QUERY
{
:query [:find (pull ?block [*])
:in $ ?start ?next
:where
(or
(and
[?block :block/marker ?marker]
[(contains? #{"NOW" "DOING"} ?marker)])
(and
[?block :block/scheduled ?d]
[(> ?d ?start)]
[(< ?d ?next)])
(and
[?block :block/deadline ?d]
[(> ?d ?start)]
[(< ?d ?next)]))]
:inputs [:1d-before :1d-after]
:group-by-page? false
}
#+END_QUERY
Query failed: All clauses ‘or’ must use same set of free vars […]
Attempt 2:
#+BEGIN_QUERY
{
:query [:find (pull ?block [*])
:in $ ?start ?next
:where
(or-join
[(and
[?block :block/marker ?marker]
[(contains? #{"NOW" "DOING"} ?marker)])]
[(and
[?block :block/scheduled ?d]
[(> ?d ?start)]
[(< ?d ?next)])]
[(and
[?block :block/deadline ?d]
[(> ?d ?start)]
[(< ?d ?next)])])]
:inputs [:1d-before :1d-after]
:group-by-page? false
}
#+END_QUERY
Query failed: Cannot parse var, expected symbol starting with ?, got: and
I assume that my attempt 2 does not work because perhaps Logseq doesn’t support or-join
?
Thanks in advance!