是否可以在datomic中为属性添加多个枚举?类似的东西:
[{:artist/name "Leonard Cohen"
:artist/countries [:country/GR :country/CA] }
在这种情况下,我会得到类似的东西 ":db.error / not-an-attribute:country / GR不是属性"
然而
[{:artist/name "Leonard Cohen"
:artist/countries :country/GR }
会起作用
答案 0 :(得分:1)
请参阅the James Bond example in the Tupelo-Datomic library。简而言之,当添加多个enum
属性时,您需要将它们包装在一个集合而不是向量中:
; Create some antagonists and load them into the db. We can specify some of the
; attribute-value pairs at the time of creation, and add others later. Note that
; whenever we are adding multiple values for an attribute in a single step (e.g.
; :weapon/type), we must wrap all of the values in a set. Note that the set
; implies there can never be duplicate weapons for any one person. As before,
; we immediately commit the new entities into the DB.
(td/transact *conn*
(td/new-entity { :person/name "James Bond" :location "London" :weapon/type #{ :weapon/gun :weapon/wit } } )
(td/new-entity { :person/name "M" :location "London" :weapon/type #{ :weapon/gun :weapon/guile } } )
(td/new-entity { :person/name "Dr No" :location "Caribbean" :weapon/type :weapon/gun } ))