(check-unique! conn id-ks & unique-datom-ks)Check unique plain entity atoms, not checking nested. ex:
(check-unique! (connect!) :city/id :city/id #uuid"586c5e02-599e-4210-993a-f74bbdfc0e16" :city/name "Havana")Check unique plain entity atoms, not checking nested. ex: - `(check-unique! (connect!) :city/id :city/id #uuid"586c5e02-599e-4210-993a-f74bbdfc0e16" :city/name "Havana")`
(check-unique-custom! conn id-ks custom-datom-ks & values)Check unique plain entity atoms, with custom where datoms. ex:
Check unique plain entity atoms, with custom where datoms. ex: - `(check-unique-custom! conn :actor/id '[[?e :actor/name ?_0] [?e :actor/city ?c] [?c :city/name ?_1]] "Lenin" "Leningrad")
(delete! conn ks id)deletes entity by matching id-ks and its value. ex:
(delete! conn :product-id 1917)deletes entity by matching id-ks and its value. ex: - `(delete! conn :product-id 1917)`
(find-all conn id-ks)(find-all conn id-ks pull-opts)finds all entries having a key, pull-opts default is '[*]. ex:
(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}}]finds all entries having a key, pull-opts default is '[*].
ex:
- `(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}}]`(find-by-id conn id-ks id)(find-by-id conn id-ks id pull-opts)finds single result by id, pull-opts default is '[*]. ex:
(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}}finds single result by id, pull-opts default is '[*].
ex:
- `(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-by-params conn kvs-map)(find-by-params conn kvs-map pull-opts)finds results by params, pull-opts default is '[*]. kvs-map uses = as default strategy,
for different matchers use v* functions as stated in examples bellow.
ex:
(find-by-params conn {:product-id 1917}) => [{:product-id 1917}](find-by-params conn {:product-id (v= 1917)}) => [{:product-id 1917}] ;equals (=)(find-by-params conn {:product-id (v-not= 1917)}) => [{:product-id 17}] ;not equals (not=)(find-by-params conn {:product-id (v> 1916)}) => [{:product-id 1917}] ;greater than (>)(find-by-params conn {:product-id (v>= 1917)}) => [{:product-id 1917}] ;greater than or equals (>=)(find-by-params conn {:product-id (v< 1918)}) => [{:product-id 1917}] ;less than (<)(find-by-params conn {:product-id (v<= 1917)}) => [{:product-id 1917}] ;less than or equals (<=)(find-by-params conn {:product-name (v-starts-with "lil")}) => [{:product-id 17 :product-name "lilek"}] ;clojure string starts with(find-by-params conn {:product-name (v-ends-with "ek")}) => [{:product-id 17 :product-name "lilek"}] ;clojure string ends with(find-by-params conn {:product-name (v-includes "le")}) => [{:product-id 17 :product-name "lilek"}] ;clojure string includes(find-by-params conn {:product-name (v-matches #"[lilek]{1,5}")}) => [{:product-id 17 :product-name "lilek"}] ;clojure regex re-matches(find-by-params conn {:product-id (v-custom-> some-fn some-arg)}) => [{:product-id 1917}] ;custom fn with argument being passed as first argument(find-by-params conn {:product-id (v-custom->> some-fn some-arg)}) => [{:product-id 1917}] ;custom fn with argument being passed as last argument(find-by-params conn {:product-id 1917} '[* {:product/category [*]]}) => {:product-id 1917, :product/category {:category/id 12}}finds results by params, pull-opts default is '[*]. kvs-map uses `=` as default strategy,
for different matchers use `v*` functions as stated in examples bellow.
ex:
- `(find-by-params conn {:product-id 1917}) => [{:product-id 1917}]`
- `(find-by-params conn {:product-id (v= 1917)}) => [{:product-id 1917}] ;equals (=)`
- `(find-by-params conn {:product-id (v-not= 1917)}) => [{:product-id 17}] ;not equals (not=)`
- `(find-by-params conn {:product-id (v> 1916)}) => [{:product-id 1917}] ;greater than (>)`
- `(find-by-params conn {:product-id (v>= 1917)}) => [{:product-id 1917}] ;greater than or equals (>=)`
- `(find-by-params conn {:product-id (v< 1918)}) => [{:product-id 1917}] ;less than (<)`
- `(find-by-params conn {:product-id (v<= 1917)}) => [{:product-id 1917}] ;less than or equals (<=)`
- `(find-by-params conn {:product-name (v-starts-with "lil")}) => [{:product-id 17 :product-name "lilek"}] ;clojure string starts with`
- `(find-by-params conn {:product-name (v-ends-with "ek")}) => [{:product-id 17 :product-name "lilek"}] ;clojure string ends with`
- `(find-by-params conn {:product-name (v-includes "le")}) => [{:product-id 17 :product-name "lilek"}] ;clojure string includes`
- `(find-by-params conn {:product-name (v-matches #"[lilek]{1,5}")}) => [{:product-id 17 :product-name "lilek"}] ;clojure regex re-matches`
- `(find-by-params conn {:product-id (v-custom-> some-fn some-arg)}) => [{:product-id 1917}] ;custom fn with argument being passed as first argument`
- `(find-by-params conn {:product-id (v-custom->> some-fn some-arg)}) => [{:product-id 1917}] ;custom fn with argument being passed as last argument`
- `(find-by-params conn {:product-id 1917} '[* {:product/category [*]]}) => {:product-id 1917, :product/category {:category/id 12}}`(insert! conn to-be-saved)(insert! conn to-be-saved check-unique)inserts entity by using a simple datomic transact. Check unique possible as an optional param. ex:
(insert! conn {:product-id 8990})(insert! conn {:product-id 8990} my-unique-check)inserts entity by using a simple datomic transact. Check unique possible as an optional param.
ex:
- `(insert! conn {:product-id 8990})`
- `(insert! conn {:product-id 8990} my-unique-check)`(transform-out result-seq)transforms d/q query results by removing db/id from root and nested maps. ex:
(transform-out {:db/id 12 :name "Rosa"}) => {:name "Rosa"}transforms d/q query results by removing db/id from root and nested maps.
ex:
- `(transform-out {:db/id 12 :name "Rosa"}) => {:name "Rosa"}`(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 for matching datoms and :db/add for new ones. ex:
(update! conn :product-id 1917 {:age 0} {:age 1917})updates entity by matching id-key and its value, intersecting found-entity with to-be-saved, therefore using :db/cas strategy for matching datoms and :db/add for new ones.
ex:
- `(update! conn :product-id 1917 {:age 0} {:age 1917})`(upsert! conn [id-ks id] to-be-saved)(upsert! conn [id-ks id] to-be-saved check-unique)upserts entity, finding it by specified id or ks and executing either insert! or update!. Check unique possible as an optional param. ex:
(upsert! conn [:product-id 1917] {:done true})(upsert! conn [:product-id 1917] {:done true} my-unique-check)upserts entity, finding it by specified id or ks and executing either **insert!** or **update!**. Check unique possible as an optional param.
ex:
- `(upsert! conn [:product-id 1917] {:done true})`
- `(upsert! conn [:product-id 1917] {:done true} my-unique-check)`(upsert-foreign! conn foreign-ks foreign-id ref-ks main-ks main-id)upserts foreign entity connected with an entity. ex:
(upsert-foreign! conn :group/id 17 :person/group :person/id 4)upserts foreign entity connected with an entity. ex: - `(upsert-foreign! conn :group/id 17 :person/group :person/id 4)`
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |