Thursday, February 3, 2022

利用 Datomic query 來取得 schema 的資訊

使用 datomic 時,有一些 query 算是輔助用的,但是非常方便,比方說,像是用來取得 datomic db schema 的 queries

實務上在開發的時候,常常會有 schema 的文件一時找不到,或是,剛好不確定,現在正在查詢的資料庫的 schema 長成什麼樣子。這一類的 query 就非常地有用。

;; find the idents of all schema elements in the system
(sort (d/q '[:find [?ident ...] :where [_ :db/ident ?ident]] db))