5

私が持っていて、 datomicスキーマとしてインストールした:user/nameと言います。:user/gender

(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) ]
   ...)

詳細については、DatomicMailingListを参照してください。楽しみ!

于 2015-09-02T17:13:15.830 に答える