Created
August 5, 2015 15:44
-
-
Save stuarthalloway/a2731a6fad64ba5e6358 to your computer and use it in GitHub Desktop.
Entity Summary
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]) | |
(defn entity-summary | |
"Returns a map with | |
:eavt vector of all eavt history datoms with eid | |
:log vector of all log entries containing those datoms" | |
[conn eid] | |
(let [log (d/log conn) | |
db (d/db conn) | |
hist (d/history db) | |
eavt (into [] (d/datoms hist :eavt eid)) | |
txids (into (sorted-set) (map :tx eavt))] | |
{:eavt eavt | |
:log (mapv (fn [txid] | |
(first (d/tx-range log txid (inc txid)))) | |
txids)})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment