Fork me on GitHub
#xtdb
<
2022-08-03
>
zeitstein07:08:15

Is there a way to achieve "show me all transactions submitted in this date range"? after-tx-id of open-tx-log would be useful, but I wouldn't know how to find an appropriate tx-id given a date (e.g. "get id of the first tx made on this date").

tatut08:08:04

wouldn’t (:tx-id (xt/db node nil start-timestamp-of-the-date)) do the trick

tatut08:08:57

so you take a db positioned at the tx time

zeitstein08:08:14

Yes, thank you!

1
zeitstein08:08:33

I'd like to support queries such as "find all docs for which this field acquired this value at this date range", without manually tracking time of field changes. Example:

t0: {:xt/id 1 :text "todo1" :status :todo}
t5: {:xt/id 1 :text "todo1" :status :done}
As far as I can tell there are two strategies: 1. Go through tx-log for e.g. t4-t7, filter :done todos, determine whether they were :todo at t3. 2. Find all :done todos, go through entity history for each to determine when they were last :todo, etc. Other ideas? Thoughts?

tatut08:08:45

go thru tx-log with-ops? true, gather all doc ids from put operations that have the desired value… then do 1 query in a historical db before the 1st tx and query the same attribute and compare

tatut08:08:28

but couldn’t you also just run the same query before the 1st tx and after the date range? depends on the exact use case

zeitstein08:08:33

> but couldn’t you also just run the same query before the 1st tx and after the date range? depends on the exact use case Oh, that's much simpler conceptually and might work 🙂

zeitstein08:08:10

So, given range t4 - t7, query for :todo at t3, then query for :done at t7 and take their intersection.

tatut08:08:32

if you can avoid doing tx-log traversal, I think it’s a good choice

2
zeitstein08:08:58

Thanks, this is much nicer!