Created
June 20, 2013 04:44
-
-
Save a2ndrade/5820364 to your computer and use it in GitHub Desktop.
Datomic: nested component entities
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
;; see http://stackoverflow.com/questions/16242750/nesting-structures-with-datomic | |
(require '[datomic.api :as d]) | |
(def uri "datomic:mem://test") | |
(d/create-database uri) | |
(def conn (d/connect uri)) | |
;; sample attributes | |
(d/transact conn [{:db/id #db/id[:db.part/db] | |
:db/ident :some/ref-value | |
:db/valueType :db.type/ref | |
:db/isComponent true | |
:db/cardinality :db.cardinality/many | |
:db.install/_attribute :db.part/db} | |
{:db/id #db/id[:db.part/db] | |
:db/ident :some/list-value | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/many | |
:db.install/_attribute :db.part/db}]) | |
;; see http://blog.datomic.com/2013/06/component-entities.html | |
;; [["a" "b" "c"]["d" "e" "f"]] | |
(d/transact conn [{:db/id #db/id[:db.part/db] | |
:some/ref-value [{ :some/list-value ["a" "b" "c"]} | |
{ :some/list-value ["d" "e" "f"]}]}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment