Fork me on GitHub
#datomic
<
2016-02-27
>
isaac02:02:20

@pesterhazy: thanks, I got it

casperc13:02:04

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?

casperc14:02:14

This is the current “versions” function, which I am now trying to make work based on a pull expression:

casperc14:02:23

(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))))

casperc14:02:35

So any pointers would be appreciated. simple_smile

val_waeselynck15:02:50

@casperc: you shoud just factor out your versions fn to return entities, not maps

val_waeselynck15:02:56

then as a post-processing step, you can either convert it to a map (using (into {} ...)) or call pull on them