Skip to content

Instantly share code, notes, and snippets.

@bahulneel
Created September 20, 2016 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bahulneel/0ac62dda604936b6a22e497bffb33769 to your computer and use it in GitHub Desktop.
Save bahulneel/0ac62dda604936b6a22e497bffb33769 to your computer and use it in GitHub Desktop.
Get all the attributes of a datomic entity (1 deep)
(->> eid
(d/q '[:find ?an ?v ?cn
:in $ ?e
:where
[?e ?a ?v]
[?a :db/ident ?an]
[?a :db/cardinality ?c]
[?c :db/ident ?cn]]
db)
(reduce (fn [m [k v c]]
(update m k (fn [o]
(if (= :db.cardinality/many c)
(if o
(conj o v)
[v])
v))))
{}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment