5

说我有: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]

我应该在查询中添加什么或者是否有自动执行它的功能?

4

2 回答 2

4

我想到了

(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]}
于 2013-02-06T08:32:27.823 回答
1

您可以使用Tupelo Datomic 库来获取给定分区的所有 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) ]
   ...)

更多信息可以在Datomic 邮件列表中找到。享受!

于 2015-09-02T17:13:15.830 回答