I have this query: https://gist.github.com/zendevil/4d0f1a844208ceb01375c686eec1f930 And basically I want to sort the ?content based on the attribute :content/event-timestamp-lng which is a long. What’s the best way to do that? Does it have to be using a custom aggregate or can it be achieved inside the query? If it has to be a custom aggregate, how do you combine the pull expression with it?
Usually you sort in clojureland, using sort-by or the likes
Datomic always returns a returnset, which has no order guarantees
(-> '[:find (pull ?content [*])
:in $ ?user-id-string
:where
[?user-id :user/id-string ?user-id-string]
[?content :content/user ?user-id]
(not [?content :content/deleted true])]
(d/q db user-id-string)
(->> (map first)
(sort-by :content/event-timestamp-lng)))