Hi is it possible to do joins in one query?
For example,
i'd like to get the results from 2 different transactions, together.
one tx has :msg/id :msg/content :msg/authorid
the other tx has :user/displayname :user/authorid
@sova If you know how these two transactions related, i.e. how to join them, you can just use a logical variable for that. Maybe I misunderstand what you exactly mean, feel free to elaborate a bit on the data you are transacting.
So I have this very costly query
Well, the query is fast, but the map is slow, because I run 3 functions inside it, and I'd like to upgrade them to query-level once I figure out all the data I need precisely
(defn get-latest-chats []
(->>
(d/q '[:find ?authorid ?content ?messageid ?timestamp
:in $ ?kind
:where
[?m :message/kind ?kind]
[?m :message/messageid ?messageid]
[?m :message/content ?content]
[?m :message/authorid ?authorid]
[?m :message/timestamp ?timestamp]]
@conn "chat")
(map (fn [[ aid content mid ts ]]
{ :authorid aid :messageid mid :content content :timestamp ts :displayname (get-display-name aid) :votes-up (get-vote-count-ups mid) :votes-down (get-vote-count-downs mid)}))
(into [])
(sort-by :timestamp)
(take 3)))
Top part gets a message, map portion puts nice keys on the data in the order it got from the result, and i also add three keys there
but I only (take 3) so can I do those 3 functions after the take
i think that will speed it up significantly
got it working ^.^