Fork me on GitHub
#datalog
<
2022-03-21
>
Pieter Koornhof08:03:41

Hi all. I’m fairly new to datalog and it’s query syntax. I have a query that gives me all todo items statuses over time

(d/q '[:find ?id ?status ?date
         :where
         [?status-id :status]
         [?status-id :doc/entry ?entry-id]
         [?entry-id :entry/text ?status]
         [?entry-id :entry/parent ?parent-id]
         [?entry-id :entry/date ?date-id]
         [?date-id :doc/date ?date]
         [?parent-id :todo ?id]]
       todo-db) 

=>

(["item3" "BUSY" "2020-01-02"]
 ["item2" "NOT-STARTED" "2020-01-01"]
 ["item3" "NOT-STARTED" "2020-01-01"]
 ["buy-food" "NOT-STARTED" "2020-01-01"])
Would there be a way to adjust the above query so only the latest status for item3 is show? example
(["item3" "BUSY" "2020-01-02"]
 ["item2" "NOT-STARTED" "2020-01-01"]
 ["buy-food" "NOT-STARTED" "2020-01-01"])
Thank you

Pieter Koornhof08:03:47

for some extra info I am using datascript and :entry/date has cardinality many