This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-27
Channels
- # beginners (106)
- # boot (124)
- # cider (11)
- # clojure (105)
- # clojure-poland (2)
- # clojure-russia (28)
- # clojurescript (89)
- # core-async (14)
- # cursive (10)
- # datomic (7)
- # emacs (12)
- # garden (5)
- # hoplon (345)
- # immutant (127)
- # mount (2)
- # off-topic (24)
- # om (24)
- # onyx (8)
- # parinfer (51)
- # proton (2)
- # slack-help (4)
- # spacemacs (1)
@pesterhazy: thanks, I got it
So I have this function “versions”, which returns all the versions of a given entity throughout the history of a db. Now I want to make a similar function, which takes an entity id and a pull expression and returns all the versions of that “pull”. How would I go about making this function?
This is the current “versions” function, which I am now trying to make work based on a pull expression:
(defn versions
"Returns all the different versions of the given entity that has existed."
[db e]
(let [txes (d/q '[:find ?tx
:in $ ?e
:where [?e _ _ ?tx]] (d/history db) e)]
(mapv (comp (partial into {}) d/touch #(d/entity (d/as-of db (first %)) e)) (sort txes))))
@casperc: you shoud just factor out your versions
fn to return entities, not maps
then as a post-processing step, you can either convert it to a map (using (into {} ...)
) or call pull
on them