(defn get-schema [db] (letfn [(attr->schema-tx [db attr] (let [e (d/entity db attr) em (->> e (map identity) (into {}))] (cond ;; attribute (:db/valueType e) (merge em {:db/id (d/tempid :db.part/db) :db.install/_attribute :db.part/db}) ;; partition (-> e :db.install/_partition) (merge em {:db/id (d/tempid :db.part/db) :db.install/_partition :db.part/db}) ;; enum or database fn :else (let [p (->> e :db/id d/part (d/entity db) :db/ident)] (cond-> em true (assoc :db/id (d/tempid p)) (:db/fn em) (assoc-in [:db/fn :fnref] nil))))))] (->> (d/q '[:find ?tx ?id :where [?e :db/ident ?id ?tx] [(str ?id) ?ident-str] (not [(.startsWith ?ident-str ":db")]) (not [(.startsWith ?ident-str ":fressian")])] db) (map (juxt first (comp (partial attr->schema-tx db) second))) (sort-by first) (partition-by first) (map #(mapv second %)))))