I’m no expert in advanced queries, but just to note that you could make things simpler (well, shorter at least) by using a regex to handle all those starts-with lines.
This selects all pages that don’t start with 0-9 or @:
@weiming looks good! I am fluent in regex and SQL and I know some Clojure, but these datalog queries are still a bit of mystery to me… that’s the thing I need to visualise!
I did a lot of tinkering around recently to get an advanced query working for me which ended up being quite tricky to work through. I have Project pages (eg [[12335]] ) and on journal pages I have job note blocks for specific jobs ie #12335 Notes with a :job property so the block title can change if needed. There are multiple levels of notes / subnotes / tasks here and I was attempting to do the below query before I learned or-join, but the query was fragile & failing if tasks weren’t at a specific indent level. I ended up spending a Sunday afternoon deep diving into this stuff to figure this out.
As I understand it, the datomic data model is just a HUUGE list of ‘datoms’ which are super basic [element-id|attribute|value] rows for everything.
There is some concept of ‘unifying’ which is a variable that appears twice in a :where represents the same value across all clauses.
Something like (or-join) allows you to control this unification to selected sub items.
My visualization on the query is a graph of conditions
The :find (?task) element is absolutely required
There are ‘facts’ you want to satisfy [(get ?prop :job) ?job][(contains? #{“TODO” “WAITING” “DOING”} ?marker)].
?task → ?prop (through or-join) → ?prop must contain :job with value :current-page
. ↳ ?marker -> must be one of TODO / WAITING / DOING
Add comment