is there a way to print the schema of a database?
@michaellan202 Check out https://github.com/cognitect-labs/day-of-datomic-cloud/blob/master/tutorial/schema_queries.clj, print whatever you want 🙂
@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)
Yea, this was the bit that confused me. So schema is just defined with datoms?
Yup
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
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?
(into #{} cat (d/q my-query db))
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 😁
Why do you think that a weird schema? Weird compared to what?
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
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 🙂. https://docs.datomic.com/cloud/best.html#idents-for-enumerated-types
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]]
db)
and the ...
is causing this errorThat syntax is only supported on on-prem peer api
that’s odd. thanks