Clojure 是否有一种规范的方法可以从特定的datomic名称空间获取所有标识?
假设我已将Clojure 是否有一种规范的方法可以从特定的datomic名称空间获取所有标识?,clojure,datomic,Clojure,Datomic,假设我已将:user/name和:user/gender安装为datomic模式 (pprint (d/q '[:find ?ident :where [?e :db/ident ?ident] [_ :db.install/attribute ?e]] (d/db conn))) 查找所有db.install/attributes #{[:db/code] [:user/gender] [:fressian/tag] [:db/u
:user/name
和:user/gender
安装为datomic模式
(pprint (d/q '[:find ?ident :where
[?e :db/ident ?ident]
[_ :db.install/attribute ?e]] (d/db conn)))
查找所有db.install/attributes
#{[:db/code] [:user/gender] [:fressian/tag] [:db/unique] [:user/name] [:db/fn]
[:db/noHistory] [:db/fulltext] [:db/lang] [:db/valueType] [:db/doc]
[:db/isComponent] [:db.install/function] [:db/cardinality] [:db/txInstant] [:db/index]}
但是,我只想列出:user名称空间中的项
[:user/gender] [:user/name]
我应该向查询中添加什么,或者是否有一个自动执行该操作的函数?我找到了答案
(d/q '[:find ?ident :where
[?e :db/ident ?ident]
[_ :db.install/attribute ?e]
[(.toString ?ident) ?val]
[(.startsWith ?val ":user")]] (d/db *conn*))
;; => #{[:user/gender] [:user/firstName]}
可以使用获取给定分区的所有EID。只需使用:
(ns xyz
(:require [tupelo.datomic :as td] ...
; Create a partition named :people (we could namespace it like :db.part/people if we wished)
(td/transact *conn*
(td/new-partition :people ))
; Find all EID's in the :people partition
(let [people-eids (td/partition-eids *conn* :people) ]
...)
有关更多信息,请参阅。享受吧