Is there a canonical way to get all identifiers from a specific namespace?

Let's say I had :user/name and :user/gender , set up as a datomatic scheme.

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

finds all 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]} 

however, I only want to list the elements in the user namespace:

 [:user/gender] [:user/name] 

What should I add to the request or is there a function that does this automatically?

+4
source share
2 answers

I get it

 (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]} 
+3
source

You can use the Dupomic Tupelo library to capture all the EIDs for this section. Just use:

 (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 in the :people partition (let [people-eids (td/partition-eids *conn* :people) ] ...) 

More information can be found in the Datomic Mailing List . Enjoy it!

+1
source

All Articles