Is there a way to query or advanced query TODO with no date marker? (Undated TODOs)
Thank you in advance.
Is there a way to query or advanced query TODO with no date marker? (Undated TODOs)
Thank you in advance.
Here you are (quick & dirty):
#+BEGIN_QUERY
{:title "⚠️NO DATE"
:query [:find (pull ?b [*])
:in $ ?start
:where
[?b :block/marker ?marker] [(= "TODO" ?marker)]
(not [?b :block/scheduled])
(not [?b :block/deadline])
]
:inputs [:today]
:result-transform (fn [result]
(->> result
(map (fn [r] (dissoc r :block/children)))
(sort-by (fn [r] (get r :block/priority "Z")))
)
)
:collapsed? false}
#+END_QUERY
Thank you. It seems that is works with SCHEDULED and DEADLINE, but not with regular date marker. Any help on it?
I’m really new to Datalog/Datomic, but this seems to work for me after fiddling around:
#+BEGIN_QUERY
{:title "Undated"
:query [:find (pull ?b [*])
:where
[?b :block/marker ?marker]
[(contains? #{"NOW" "LATER" "DOING" "TODO" "WAITING"} ?marker)]
(not [?b :block/ref-pages ?p]
[?p :block/journal? true]) ]
:collapsed? false}]}
#+END_QUERY
I don’t fully understand why it works, so there may be some flaws in this.
Hope it helps!
I’m no datalog expert but figured I could give a shallow reading of that code in case others come here and wonder what it does.
In order of appearance, here’s what this Datalog query does:
:query
to :find
an entity assigned to the variable ?b
(you could also call it ?block
to make this more readable at a glance. This is a pull
query, which applies a search pattern to a hierarchical collection of entities.
?b
to a result a result…
:where
the entity is a :block
with an attribute marker
…contains?
the one of the following in its content: ${"NOW "LATER" …
…not
reference a journal page (not 100% sure I’ve interpreted this one correctly)You can find the datomic query documentation here. In particular, if you plan to write more datomic queries going forward, this query reference is very handy.
Thank you! Great suggestion on renaming ?b
to ?block
. I didn’t fully realize that this was essentially a variable that I defined. Could you explain how the ?p
works?
I’m still not exactly sure what :block/ref-pages
and :block/journal
are, wasn’t able to find any documentation on it.
If you have enable Settings > Advanced > Developer mode
you can right-click on blocks or pages and see block data
What they are used for: db-schema
:block/journal boolean, is this a journal true/false
:block/ref-pages links to the page the TODO is found on