Tag based task aggregator

It seems you use this, because the query throws an error.
However this is not the correct solution to that. Instead your or should be an or-join, like this.

(or-join [?p ?b]
  [?b :block/path-refs ?p]
  (and 
    [?page :block/tags ?p] 
    [?b :block/path-refs ?page]
  )
)

To explain, an or statement will be bound to the rest of the query.

“All clauses used in an or clause must use the same set of variables, which will unify with the surrounding query. This includes both the arguments to nested expression clauses as well as any bindings made by nested function expressions. Datomic will attempt to push the or clause down until all necessary variables are bound, and will throw an exception if that is not possible.”
From Query | Datomic
(Although Logseq uses the datascript implementation and not datomic, they are similar.)

“An or-join is similar to an or clause, but it allows you to specify which variables should unify with the surrounding clause; only this list of variables needs binding before the clause can run. The variables specifies which variables should unify.”

In our case it is the variables ?p and ?b. So we write or-join [?p ?b]
The variable ?page is only relevant within the or-join.

Otherwise yes, tags and direct references are much easier to work with than namespaces :wink: kudos!

3 Likes