Fork me on GitHub
#datomic
<
2021-03-28
>
zendevil01:03:40

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?

thumbnail11:03:07

Usually you sort in clojureland, using sort-by or the likes

thumbnail11:03:24

Datomic always returns a returnset, which has no order guarantees

souenzzo00:03:20

(-> '[: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)))