-
-
Save nivekuil/bc8d8d896f0db23a4d015946100247ca to your computer and use it in GitHub Desktop.
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
(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