Utility functions for working with Datomic.
Only includes functions that don't depend on Datomic APIs.
Utility functions for working with Datomic. Only includes functions that don't depend on Datomic APIs.
(datascript-schema compact-schema)
Generate Datascript schema from a compact schema format.
See datomic-schema
.
Generate Datascript schema from a compact schema format. See [[datomic-schema]].
(datomic-schema compact-schema)
Generate Datomic schema from a compact schema format.
compact-schema
is a map from idents to flags. See expand-flags
. Example:
(datomic-schema {:foo [:db.type/string :db.unique/identity]
:bar [:db.type/long :db.cardinality/many]})
=> (#:db{:ident :foo,
:cardinality :db.cardinality/one,
:valueType :db.type/string
:unique :db.unique/identity}
#:db{:ident :bar,
:cardinality :db.cardinality/many,
:valueType :db.type/long})
Generate Datomic schema from a compact schema format. `compact-schema` is a map from idents to flags. See [[expand-flags]]. Example: ``` (datomic-schema {:foo [:db.type/string :db.unique/identity] :bar [:db.type/long :db.cardinality/many]}) => (#:db{:ident :foo, :cardinality :db.cardinality/one, :valueType :db.type/string :unique :db.unique/identity} #:db{:ident :bar, :cardinality :db.cardinality/many, :valueType :db.type/long}) ```
(ent-keys req)
(ent-keys req opt)
Like clojure.spec.alpha/keys
, but only allow keys in req
or opt
.
Intended for use with a pull
ed entity. Handles cardinality many values
correctly. Only checks the current entity; the values of any :db.type/ref
attributes will be assumed valid.
Like `clojure.spec.alpha/keys`, but only allow keys in `req` or `opt`. Intended for use with a `pull`ed entity. Handles cardinality many values correctly. Only checks the current entity; the values of any `:db.type/ref` attributes will be assumed valid.
(eval-tx-fns db tx)
Evaluate any transaction functions in tx
, returning transaction data.
Only works with classpath transaction functions, not database functions.
Evaluate any transaction functions in `tx`, returning transaction data. Only works with classpath transaction functions, not database functions.
(expand-flags flags)
Generate Datomic schema from a collection of flags.
Example:
(expand-flags [:foo :db.type/string :db.cardinality/one
"this is a foo" [:db/id "some-id"]])
=> #:db{:ident :foo,
:valueType :db.type/string,
:cardinality :db.cardinality/one,
:doc "this is a foo",
:id "some-id"}
Generate Datomic schema from a collection of flags. Example: ``` (expand-flags [:foo :db.type/string :db.cardinality/one "this is a foo" [:db/id "some-id"]]) => #:db{:ident :foo, :valueType :db.type/string, :cardinality :db.cardinality/one, :doc "this is a foo", :id "some-id"} ```
(tag-eids ds-schema datoms)
Convert all EIDs in datoms
to tagged literals.
ds-schema
: Datascript schema.
For example, 123
would become #trident/eid "123"
.
Convert all EIDs in `datoms` to tagged literals. `ds-schema`: Datascript schema. For example, `123` would become `#trident/eid "123"`.
(translate-eids ds-schema eids tx)
(wrap-coll ent-value)
Ensure that ent-value
is wrapped in a vector or set.
Needed because Datomic pull
wraps values in collections only sometimes,
depending on attribute cardinality.
Ensure that `ent-value` is wrapped in a vector or set. Needed because Datomic `pull` wraps values in collections only sometimes, depending on attribute cardinality.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close