2013-02-06 123 views
3

說我已將:user/name:user/gender安裝爲datomic模式。是否有一種規範的方法來抓取特定數據組分區中的所有元素?

(pprint (d/q '[:find ?ident :where 
       [?e :db/ident ?ident] 
       [_ :db.install/attribute ?e]] (d/db conn))) 

但是找到所有的db.install /屬性

#{[: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/gender] [:user/name] 

我應該怎麼添加到查詢或有沒有自動執行的功能?

回答

2

我想通了

(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]} 
0

您可以使用the Tupelo Datomic library抓住所有新發傳染病對一個給定的分區。只需使用:

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

更多信息可在the Datomic Mailing List中找到。請享用!

相關問題