(=> & conditions)
Quotes symbols starting from ? and _
symbol in given condition form.
(let [attr :payment/id
id 100]
(=> [?payment attr ?id] id))
;; [[?payment :payment/id ?id] 100]
Quotes symbols starting from ? and `_` symbol in given condition form. (let [attr :payment/id id 100] (=> [?payment attr ?id] id)) ;; [[?payment :payment/id ?id] 100]
(add-input q binding source & [expand-coll?])
Adds query input. Last optional agrument turns automatic expanding of collection source into collection binding
Adds query input. Last optional agrument turns automatic expanding of collection source into collection binding
(find bindings)
(find q bindings & [override?])
Adds bindings to query :find
Adds bindings to query `:find`
(find-coll binding)
(find-coll q binding)
Adds collection binding to query :find
Adds collection binding to query `:find`
(find-scalar binding)
(find-scalar q binding)
Adds scalar binding to query :find
Adds scalar binding to query `:find`
(in q src)
(in q binding source & inputs)
Adds query input. If binding for input is not specified, its added as $
as first argument.
If source is set?
, the corresponding collection binding is added
Adds query input. If binding for input is not specified, its added as `$` as first argument. If source is `set?`, the corresponding collection binding is added
(map->query conditions-map)
(map->query src conditions-map)
Transforms key-value map into query map. By default entity is bound as ?e but this can be redefined with :find
meta supplied with map.
Another supported meta attributes are :as
for defining query keys and :first
which will return scalar value
(map->query {:user/id 1}) ;; => {:query {:find [[?e ...]], :where [[?e :user/id ?user-id]], :in [?user-id]}, :args [1]}
(map->query ^{:find '?user} {:user/id 1}) ;; => {:query {:find [[?user ...]], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}
(map->query ^{:find '?user :as :user} {:user/id 1}) ;; => {:query {:find [?user], :keys [:user], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}
Transforms key-value map into query map. By default entity is bound as ?e but this can be redefined with `:find` meta supplied with map. Another supported meta attributes are `:as` for defining query keys and `:first` which will return scalar value (map->query {:user/id 1}) ;; => {:query {:find [[?e ...]], :where [[?e :user/id ?user-id]], :in [?user-id]}, :args [1]} (map->query ^{:find '?user} {:user/id 1}) ;; => {:query {:find [[?user ...]], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]} (map->query ^{:find '?user :as :user} {:user/id 1}) ;; => {:query {:find [?user], :keys [:user], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}
(where q condition)
(where q condition value)
Adds condition to query. Accepts optional value.
If value is nil, condition is transformed into (not [...]).
If value is set?
, the corresponding collection binding is addded
Adds condition to query. Accepts optional value. If value is nil, condition is transformed into (not [...]). If value is `set?`, the corresponding collection binding is addded
(where* q conditions)
Adds multiple conditions/values from supplied collection to query using where
.
If condition needs to have supplied value, it should be wrapped in vector eg
(where* q
[[?e :order/id]
[['?e :order/customer '?c] customer]
Adds multiple conditions/values from supplied collection to query using `where`. If condition needs to have supplied value, it should be wrapped in vector eg (where* q [[?e :order/id] [['?e :order/customer '?c] customer]
(where-> q & conditions)
Adds multiple conditions/values to query using where
.
If condition needs to have supplied value, it should be wrapped in vector eg
(where-> q
['?e :order/id]
[['?e :order/customer '?c] customer]
Adds multiple conditions/values to query using `where`. If condition needs to have supplied value, it should be wrapped in vector eg (where-> q ['?e :order/id] [['?e :order/customer '?c] customer]
(where-not q condition)
(where-not q condition value)
Adds not
condition to query. Accepts optional value.
If value is set, it's used as function to filter out conditions
Adds `not` condition to query. Accepts optional value. If value is set, it's used as function to filter out conditions
(where-not* q conditions)
Adds multiple conditions/values from supplied collection to query using where-not
.
If condition needs to have supplied value, it should be wrapped in vector eg
(where-not* q
[[?e :order/cancelled]
['?e :order/status '?s] status])
Adds multiple conditions/values from supplied collection to query using `where-not`. If condition needs to have supplied value, it should be wrapped in vector eg (where-not* q [[?e :order/cancelled] ['?e :order/status '?s] status])
(where? q cond-vals)
(where? q condition value)
Adds condition to query only if supplied value is not nil. Accepts either query condition and value or map/list/vector of conditions and values eg: (where? q {'[?e :order/id ?id] id '[?e :order/customer ?c] customer} (where? q ['[?e :order/id ?id] id '[?e :order/customer ?c] customer]
Adds condition to query only if supplied value is not nil. Accepts either query condition and value or map/list/vector of conditions and values eg: (where? q {'[?e :order/id ?id] id '[?e :order/customer ?c] customer} (where? q ['[?e :order/id ?id] id '[?e :order/customer ?c] customer]
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close