Skip to content

Instantly share code, notes, and snippets.

@stuarthalloway
Created August 5, 2015 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuarthalloway/a2731a6fad64ba5e6358 to your computer and use it in GitHub Desktop.
Save stuarthalloway/a2731a6fad64ba5e6358 to your computer and use it in GitHub Desktop.
Entity Summary
(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