A Clojure library with handful tools for helping the usage of datomic-free
[org.clojars.majorcluster/datomic-helper "LAST RELEASE NUMBER"]
export GPG_TTY=$(tty) && lein deploy clojars
Functions | Description |
---|---|
transform-out [result] | transforms d/q query results by removing db/id from root and nested maps (transform-out {:db/id 12 :name "Rosa"}) => {:name "Rosa"} |
find-by-id [conn id-ks id & pull-opts] | finds single result by id, pull-opts default is [*] (find-by-id conn :product-id 1917) => {:product-id 1917} (find-by-id conn :product-id 1917 [* {:product/category [*]]}) => {:product-id 1917, :product/category {:category/id 12}} |
find-all [conn id-ks & pull-opts] | finds all entries having a key, pull-opts default is [*] (find-all conn :product-id) => [{:product-id 24},{:product-id 1917}] (find-all conn :product-id [* {:product/category [*]]) => [{:product-id 24, :product/category {:category/id 15}},{:product-id 1917, :product/category {:category/id 12}}] |
update! [conn id-ks id found-entity to-be-saved] | updates entity by matching id-key and its value, intersecting found-entity with to-be-saved, therefore using :db/cas strategy, not updating if the value before is not the same anymore in db (update! conn :product-id 1917 {:age 0} {:age 1917}) |
insert! [conn to-be-saved] | inserts entity by using a simple datomic transact (insert! conn {:product-id 8990}) |
upsert! [conn [id-ks id] to-be-saved] | upserts entity, finding it by specified id or ks and executing either insert! or update! (upsert! conn [:product-id 1917] {:done true}) |
insert-foreign! [conn parent-ks parent-id child-ks child] | inserts foreign entity connected to a parent entity by using a simple datomic transact (insert-foreign! conn :product-id 8990 ) |
upsert-foreign! [conn [id-ks id] parent-ks parent-id child-ks to-be-saved] | upserts foreign entity connected with a parent, finding it by specified id or ks and executing either insert-foreign! or update! (upsert! conn [:product-id 1917] {:done true}) |
Common parameters | Description |
---|---|
configs | having all keys as optional: {:indexed [:ks...] :components [:ks...] :historyless [:ks...]} a key sent in the list of the configs will have in :indexed = db/indexed true in :components = db/isComponent true in :historyless = db/noHistory true" |
Functions | Description |
---|---|
schema-to-datomic [definition configs] | receives a prismatic/schema entity definition and converts it to datomic schema definition. definition: see prismatic/schema documentation configs: see configs at Common parameters |
schemas-to-datomic [definitions configs] | receives a vector of prismatic/schema entities definitions and converts them to datomic schema definitions. definitions: see prismatic/schema documentation configs: see configs at Common parameters |
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close