Since the Datomic schema itself is stored in Datomic, how can I query Datomic to get the installed schema? I want to get only the user level diagram, excluding the system level diagram, which has things like partitions.
According to the Datomic docs , the user level scheme must be installed in the partition :db.part/db. The following function gets all the attributes of the schema in this section, given the Datomic connection.
:db.part/db
(defn get-user-schema [conn] (d/q '[:find ?id :where [?e :db/ident ?id] [_ :db.install/attribute ?e] [?e :db.install/partition :db.part/db]] (d/db conn)))
Related: Is there a canonical way of capturing all ids from a specific separation element?
Datomic Datalog, , , :
[:find ?attr ?type ?card :where [_ :db.install/attribute ?a] [?a :db/valueType ?t] [?a :db/cardinality ?c] [?a :db/ident ?attr] [?t :db/ident ?type] [?c :db/ident ?card]]
- :
http://www.learndatalogtoday.org/chapter/4 ( 2 ).