Created
September 20, 2016 15:15
-
-
Save bahulneel/0ac62dda604936b6a22e497bffb33769 to your computer and use it in GitHub Desktop.
Get all the attributes of a datomic entity (1 deep)
This file contains hidden or 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
(->> 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