I have a query that looks like:
:find (pull ?b [...]) (pull ?p [...])
:where
(or-join [?b ?p]
(and
[?b :block/properties ?bp]
[(get ?bp :project) ?proj]
[?p :block/original-name ?projName]
[(contains? ?proj ?projName)]
)
[?b :block/page ?p] ;; If I comment this out, it loads the correct page when linked via :project, but not otherwise
)
;; there's more going on in this query, context below
The idea is that I want to load [block, page]
tuples, where the page is either a page linked in a “project” property, or if that doesn’t exist, just the page the block is on.
As an illustrative example:
Page: Journal 2024-02-07
- TODO Do a thing
project:: [[Some Project]]
Page: Some Project
- TODO Do another thing
My query should return [[Do a thing, Some Project], [Do another thing, Some Project]]
. What it currently returns is [[Do a thing, 2024-02-07], [Do another thing, Some Project]]
.
I could have sworn this incantation worked at some point, but it isn’t working at present (I’m on 0.10.5
). I’ve written a ton of Datascript queries at this point, but unfortunately still have no idea what I’m doing, especially with or-join
.
Context: I’ve built a terminal task management tool on top of Logseq (via the HTTP API, repo) inspired by GTD (and Everdo in particular).
You can see the code/query in question here, and other queries in the project here, here, and here.
Any help is much appreciated!