Fork me on GitHub
#datomic
<
2023-08-14
>
Chip04:08:51

Sorry. Noob here. I’m missing something. Working with Datomic Cloud, dev-local. I cannot figure out how to inspect the schema. Where’s the data dictionary or whatever it might be called? How can I tell what’s in the thing? Are the use cases such that structure inspection (never mind backup) isn’t necessary?

jasonjckn05:08:19

run datomic console

gratitude-thank-you 2
favila06:08:02

Without console: Entity 0 (also called :db.part/db) references all partitions and schema, so you can query or pull from it. You can also just query attribute attributes (like :db/valueType for eg) directly. All schema lives alongside data in the same database as mostly-normal entities

danieroux08:08:18

This is our snippet, on datomic-cloud:

(defn- our-attr? [attr]
  (and
    (not (.startsWith (namespace attr) "db"))
    (not (.startsWith (namespace attr) "fressian"))))

(defn schema
  "Returns a data representation of db schema."
  [db]
  (->> (d/pull db '{:eid 0 :selector [{:db.install/attribute [*]}]})
    :db.install/attribute
    (map #(update % :db/valueType :db/ident))
    (map #(update % :db/cardinality :db/ident))))

(defn our-schema
  "Returns a data representation of our schema, excluding Datomic attrs."
  [db]
  (filter
    #(our-attr? (:db/ident %))
    (schema db)))

gratitude-thank-you 2
1
Chip13:08:29

I’m overwhelmed by the support here. Sincerely, thank you.