有 2 个关于 datomic 属性的查询。1.如果我知道属性名称(字符串),我如何检查该属性是否已经在模式中定义?2. 根据我对 datomic 的实验,我看到 datomic 对待带有冒号前缀和不带有冒号前缀的属性是一样的。即,如果我们创建名为“foo”和“:foo”的属性,它们是一回事。这是真的?这是一个限制吗?
我正在使用带有 groovy 的 datomic。下面是用于创建属性的代码。除了名称之外,还输入了其他参数。
static def createAttribute(String name, String type, String description, Connection connection) {
List schema = [[
':db/id': Peer.tempid(':db.part/db'),
':db/ident' : name,
':db/valueType': type,
':db/cardinality': ':db.cardinality/one',
':db/doc': description,
':db.install/_attribute': ':db.part/db'
]]
connection.transact(schema).get()
我用来验证属性存在的查询是
def attributeFor(String attributeName, Database db) {
db.entity(attributeName).get(':db.install/_attribute')
}
如果我用“foo”作为属性名和“attributeFor”方法“:foo”作为属性名调用“createAttribute”,我会得到一个结果。即 "foo" 和 ":foo" 被视为相同。如何创建和查询名称中包含冒号前缀的属性?