Created
October 6, 2017 15:54
-
-
Save benkamphaus/94af89e680ef9220549494d8f4f5bde9 to your computer and use it in GitHub Desktop.
Group all facts from a history DB for an entity in Datomic by transaction, using sorted map to order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[datomic.api :as d]) | |
;; for a particular entity, find it's entire tx history | |
(defn e->tx-history [db ent-id] | |
(->> (d/datoms (d/history db) :eavt ent-id) | |
(map (fn [[e a v tx assert]] | |
[e | |
(-> db (d/pull '[:db/ident] a) :db/ident) | |
v | |
tx | |
assert])) | |
(group-by #(nth % 3)) | |
(into (sorted-map)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment