Skip to content

Instantly share code, notes, and snippets.

@nivekuil
Created September 30, 2020 08:19
Show Gist options
  • Save nivekuil/bc8d8d896f0db23a4d015946100247ca to your computer and use it in GitHub Desktop.
Save nivekuil/bc8d8d896f0db23a4d015946100247ca to your computer and use it in GitHub Desktop.
(put {:crux.db/id {[:user/id 1] :login-details} :user/id 1 :user/name "foo" :user/password "bar"})
(put {:crux.db/id {[:user/id 1] :favorites} :user/id 1 :user/favorite-food "pie" :user/favorite-animal "cow"})
(defn attr [ident attr]
(dissoc (crux/entity (db) {ident attr}) :crux.db/id))
(defn entity [ident]
(let [[table id] ident]
(dissoc
(->> (q {:find '[(eql/project ?e [*])]
:where [['?e table id]]})
(map peek)
(into {} merge))
:crux.db/id)))
(attr [:user/id 1] :login-details)
;; {:user/id 1, :user/name "foo", :user/password "bar"}
(entity [:user/id 1])
;; {:user/id 1,
;; :user/favorite-food "pie",
;; :user/favorite-animal "cow",
;; :user/name "foo",
;; :user/password "bar"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment