Liking cljdoc? Tell your friends :D

datomic-helper.entity


check-unique!clj

(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")`
sourceraw docstring

check-unique-custom!clj

(check-unique-custom! conn id-ks custom-datom-ks & values)

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")
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")
sourceraw docstring

delete!clj

(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)`
sourceraw docstring

find-allclj

(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}}]`
sourceraw docstring

find-by-idclj

(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}}`
sourceraw docstring

find-by-paramsclj

(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}}`
sourceraw docstring

insert!clj

(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)`
sourceraw docstring

transform-outclj

(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"}`
sourceraw docstring

update!clj

(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})`
sourceraw docstring

upsert!clj

(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)`
sourceraw docstring

upsert-foreign!clj

(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)`
sourceraw docstring

v-custom->clj

(v-custom-> custom-fn & args)
source

v-custom->>clj

(v-custom->> custom-fn & args)
source

v-ends-withclj

(v-ends-with v)
source

v-includesclj

(v-includes v)
source

v-matchesclj

(v-matches v)
source

v-not=clj

(v-not= v)
source

v-starts-withclj

(v-starts-with v)
source

v<clj

(v< v)
source

v<=clj

(v<= v)
source

v=clj

(v= v)
source

v>clj

(v> v)
source

v>=clj

(v>= v)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close