Clojure 向现有datomic架构添加属性
我正在尝试向现有的datomic模式添加一个属性,新属性为Clojure 向现有datomic架构添加属性,clojure,schema,datomic,Clojure,Schema,Datomic,我正在尝试向现有的datomic模式添加一个属性,新属性为 {:db/id #db/id[:db.part/db] :db/ident :user-deets/enriched :db/valueType :db.type/boolean :db/cardinality :db.cardinality/one :db.install/_attribute :db.part/db} 当我尝试将其作为事务提交(如中所述)时,请执行以下操作 (datomic/query '[{:
{:db/id #db/id[:db.part/db]
:db/ident :user-deets/enriched
:db/valueType :db.type/boolean
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}
当我尝试将其作为事务提交(如中所述)时,请执行以下操作
(datomic/query '[{:db/id #db/id[:db.part/db]
:db/ident :user-deets/enriched
:db/valueType :db.type/boolean
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}] (database/get-db))
我得到一个错误,我的查询中没有:find子句
为了将属性添加到我的datomic databases架构中,我应该如何提交此事务?您的代码无法工作,因为您使用了错误的函数 您想使用
交易
您的代码无法工作,因为您使用了错误的函数 您想使用
交易
为了更方便地创建属性和使用其他Datomic功能,您可能希望尝试。它将允许您创建如下属性:
(:require [tupelo.datomic :as td])
; Create some new attributes. Required args are the attribute name (an optionally namespaced
; keyword) and the attribute type (full listing at http://docs.datomic.com/schema.html). We wrap
; the new attribute definitions in a transaction and immediately commit them into the DB.
(td/transact *conn* ; required required zero-or-more
; <attr name> <attr value type> <optional specs ...>
(td/new-attribute :person/name :db.type/string :db.unique/value) ; each name is unique
(td/new-attribute :person/secret-id :db.type/long :db.unique/value) ; each secret-id is unique
(td/new-attribute :weapon/type :db.type/ref :db.cardinality/many) ; one may have many weapons
(td/new-attribute :location :db.type/string) ; all default values
(td/new-attribute :favorite-weapon :db.type/keyword )) ; all default values
为了更方便地创建属性和使用其他Datomic功能,您可能希望尝试。它将允许您创建如下属性:
(:require [tupelo.datomic :as td])
; Create some new attributes. Required args are the attribute name (an optionally namespaced
; keyword) and the attribute type (full listing at http://docs.datomic.com/schema.html). We wrap
; the new attribute definitions in a transaction and immediately commit them into the DB.
(td/transact *conn* ; required required zero-or-more
; <attr name> <attr value type> <optional specs ...>
(td/new-attribute :person/name :db.type/string :db.unique/value) ; each name is unique
(td/new-attribute :person/secret-id :db.type/long :db.unique/value) ; each secret-id is unique
(td/new-attribute :weapon/type :db.type/ref :db.cardinality/many) ; one may have many weapons
(td/new-attribute :location :db.type/string) ; all default values
(td/new-attribute :favorite-weapon :db.type/keyword )) ; all default values
(td/transact (database/get-db)
(td/new-attribute :user-deets/enriched :db.type/boolean))