Liking cljdoc? Tell your friends :D

datomic-helper

A Clojure library designed to bring handful tools for using datomic-free

Clojars Project

A Clojure library designed to bring handful tools for using datomic-free

Usage

  • Add the dependency:
[org.clojars.majorcluster/datomic-helper "LAST RELEASE NUMBER"]

Publish

Requirements

  • Leiningen (of course 😄)
  • GPG (mac => brew install gpg)
  • Clojars account
  • Enter clojars/tokens page in your account -> generate one and use for password
export GPG_TTY=$(tty) && lein deploy clojars

Documentation

datomic-helper/entity

FunctionsDescription
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]finds single result by id
(find-by-id conn :product-id 1917) => {:product-id 1917}
find-all [conn id-ks]finds all entries having a key
(find-all conn :product-id) => [{:product-id 24},{:product-id 1917}]
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})

datomic-helper/schema-transform

Common parametersDescription
configshaving 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"
FunctionsDescription
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