Fork me on GitHub
Ivan Koz12:07:27

Hi i need to query an attribute of the document on two different valid-times and output it at once any examples of such a query?


hey @UH16CGZC2 👋 XT only does single-point-in-time queries, so I'd recommend making two queries at the two different valid-times and combining them in your application


You can embed other history calls and queries inside a top-level query, if that might be of use:

🙏 1
Ivan Koz12:07:38

oh alright, and i choose target valid time when acquiring db instance right?

👍 1
Ivan Koz14:07:44

Look at that monster, any way to simplify it? Maybe by pull syntax or something.


It looks like you could cut out 3 of the clauses using pull, yep: :find [(pull ?clan [:clan/name]) (pull ?profile [:profile/name :profile/rank]) ?cbw-old ?cbw ?cbw-diff]


a differently shaped monster, perhaps 🙂


I guess the more Datalog you write the more you get used to it, and the simpler it ends up looking...

Ivan Koz15:07:13

sure, it works for everything 😃

Ivan Koz16:07:41

is it possible to add something else to a join when building nested results using pull, like ?cid

(q '{:find [(pull ?clan [:clan/name {:clan/members [:profile/name [?cid :as :cid]]}])]
     :where [[?clan :clan/name "..."]
             [?clan :xt/id ?cid]]})

expected output
#{[{:clan/name    "..."
    :clan/members [{:profile/name "..."
                    :cid          "..."}


sadly not, you can't mix pull and regular clauses like that. The pull always happens as the ~last step in the query execution


You could possible wrap the result of a pull in an outer-query, then use get-in again...but I'm not sure that's ultimately simpler 😅