Fork me on GitHub
Michael Lan18:04:13

is there a way to print the schema of a database?


@michaellan202 since schema is still plain data within datomic, you can query for it and print it (using same schema attributes that you use to define it)

Michael Lan18:04:14

Yea, this was the bit that confused me. So schema is just defined with datoms?

Michael Lan18:04:47

Thank you both!


[?n :db/ident ?ident] ^ give me all the named entities in the database


then you can pull out their :db/valueType or :db/cardinality

👍 1
Michael Lan19:04:22

There seems to be a lot of duplicates? I vaguely remember from a video how to remove duplicates by putting the output into a set but I can’t recall how to do it. Any tips?

Joe Lane19:04:01

(into #{} cat (d/q my-query db))

Michael Lan19:04:22

Thanks. It turns out there weren’t any duplicates, just a very weird schema. I’m looking at the mbrainz-subset sample dataset right now 😁

Joe Lane19:04:22

Why do you think that a weird schema? Weird compared to what?

Michael Lan19:04:47

There are a lot of :language/<3 random letter> idents, here is a snippet of the output:

#{:language/mmz :language/thq :language/mdc :language/cno :language/tdk
  :language/orr :country/CX :language/nxu :medium.format/dvd
  :language/xku :country/MV :language/bil :language/wri :language/zoo
  :language/bdu :language/tuc :language/mlh :language/anf :language/kdi
  :language/ahi :language/mec :language/kxd :language/bau :country/GG
  :language/osa :release/script :language/nki :language/acw
  :language/hmi :country/SN :language/lcp :language/ces :language/rej
  :medium.format/vinyl :language/cog :language/bfi :language/sfs
  :language/brz :language/dae :label/type :language/zuh :language/phw
  :language/uam :language/lbu :language/tak :language/bmd :language/chz
  :language/jia :language/pic :language/nfa :language/jel :language/gic
  :language/kzr :language/yiy :language/lmh :language/ktq :language/trh
  :language/hix :language/krl :medium.format/cassette :language/ntj
  :language/kvm :language/sld :language/apl :language/guo :script/Lisu
  :language/bfx :language/bcl :language/duv :language/pcj :language/bjr
  :language/oaa :language/mbi :country/BQ :language/etr :language/tsd

Lennart Buit21:04:13

It’s pretty common to define enumerable values as idents. Allows you to refer to them with keywords (that check whether the ident exists!) instead of something like ordinal values. In your particular example, these idents appear to be ISO 639-2 language codes 🙂.

👍 1
Michael Lan22:04:22

What does Only find-rel elements are allowed in client :find mean? I am trying to do:

(d/q '[:find [?month ...]
         :where [_ :release/month ?month]]
and the ... is causing this error


That syntax is only supported on on-prem peer api

Michael Lan22:04:59

that’s odd. thanks