Skip to content

Commit 277f533

Browse files
darkleaftonsky
authored andcommitted
Expose a schema as a part of the public API.
1 parent 0eca251 commit 277f533

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/datascript/core.cljc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@
190190
Used internally in db (de)serialization. See also [[datom]]."}
191191
init-db db/init-db)
192192

193+
; Schema
194+
195+
(def ^{:arglists '([db])
196+
:doc "Returns a schema of a database."}
197+
schema db/-schema)
193198

194199
; Filtered db
195200

test/datascript/test/issues.cljc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@
4343
(ds/db-with [[:db/add 1 :attr "aa"]]))]
4444
(t/is (= [[(ds/datom 1 :attr :aa)] [(ds/datom 1 :attr "aa")] nil]
4545
(clojure.data/diff db1 db2)))))
46+
47+
(deftest ^{:doc "Expose a schema as a part of the public API."}
48+
issue-381
49+
(let [schema {:aka {:db/cardinality :db.cardinality/many}}
50+
db (ds/empty-db schema)]
51+
(t/is (= schema (ds/schema db)))))

0 commit comments

Comments
 (0)