Liking cljdoc? Tell your friends :D

fmnoise.qb


->bindingclj

(->binding v & [uniq?])
source

add-inputclj

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

data->queryclj

(data->query conditions)
(data->query src conditions)

Transforms map or vector into query map. Additional query options can be supplied with meta attached to conditions: :in for source binding (defaults to $) :find for defining result binding (defaults to ?e) :from for defining entity binding (defaults to ?e) :as for defining query keys :first which will return scalar value :aggregate which can contain either a keyword or collection of function symbol and keyword in any order like [:order/total 'sum] or ['sum :order/total] when aggregation is used, :with instruction is automatically added

(data->query {:user/id 1 :user/type :admin}) ;; => {:query {:find [[?e ...]], :where [[?e :user/id ?user-id] [?e :user/type ?user-type]], :in [?user-id ?user-type]}, :args [1 :admin]}

(datq->query ^{:find '?user} {:user/id 1}) ;; => {:query {:find [[?user ...]], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}

(data->query ^{:find '?user :as :user} {:user/id 1}) ;; => {:query {:find [?user], :keys [:user], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}

(data->query ^{:aggregate ['sum :order/total]} {:order/id '_}) ;; => {:query {:find [(sum ?order-total) .], :where [[?e :order/id] [?e :order/total ?order-total]]}}

(data->query ^{:aggregate :order/customer} {:order/id '_}) ;; => {:query {:find [[?order-customer ...]], :where [[?e :order/id] [?e :order/customer ?order-customer]]}}

(data->query [:user/id 1 :user/type :admin]) ;; => {:query {:find [[?e ...]], :where [[?e :user/id ?user-id] [?e :user/type ?user-type]], :in [?user-id ?user-type]}, :args [1 :admin]}

(data->query ^{:find '?user} [:user/id 1]) ;; => {:query {:find [[?user ...]], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}

(data->query ^{:find '?user :as :user} [:user/id 1]) ;; => {:query {:find [?user], :keys [:user], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}

(data->query ^{:aggregate ['sum :order/total]} [:order/id '_]) ;; => {:query {:find [(sum ?order-total) .], :where [[?e :order/id] [?e :order/total ?order-total]]}}

(data->query ^{:aggregate :order/customer} [:order/id '_]) ;; => {:query {:find [[?order-customer ...]], :where [[?e :order/id] [?e :order/customer ?order-customer]]}}

Transforms map or vector into query map. Additional query options can be supplied with meta attached to `conditions`:
`:in` for source binding (defaults to $)
`:find` for defining result binding (defaults to ?e)
`:from` for defining entity binding (defaults to ?e)
`:as` for defining query keys
`:first` which will return scalar value
`:aggregate` which can contain either a keyword or collection of function symbol and keyword in any order like [:order/total 'sum] or ['sum :order/total]
when aggregation is used, `:with` instruction is automatically added

(data->query {:user/id 1 :user/type :admin})
;; => {:query {:find [[?e ...]], :where [[?e :user/id ?user-id] [?e :user/type ?user-type]], :in [?user-id ?user-type]}, :args [1 :admin]}

(datq->query ^{:find '?user} {:user/id 1})
;; => {:query {:find [[?user ...]], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}

(data->query ^{:find '?user :as :user} {:user/id 1})
;; => {:query {:find [?user], :keys [:user], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}

(data->query ^{:aggregate ['sum :order/total]} {:order/id '_})
;; => {:query {:find [(sum ?order-total) .], :where [[?e :order/id] [?e :order/total ?order-total]]}}

(data->query ^{:aggregate :order/customer} {:order/id '_})
;; => {:query {:find [[?order-customer ...]], :where [[?e :order/id] [?e :order/customer ?order-customer]]}}

(data->query [:user/id 1 :user/type :admin])
;; => {:query {:find [[?e ...]], :where [[?e :user/id ?user-id] [?e :user/type ?user-type]], :in [?user-id ?user-type]}, :args [1 :admin]}

(data->query ^{:find '?user} [:user/id 1])
;; => {:query {:find [[?user ...]], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}

(data->query ^{:find '?user :as :user} [:user/id 1])
;; => {:query {:find [?user], :keys [:user], :where [[?user :user/id ?user-id]], :in [?user-id]}, :args [1]}

(data->query ^{:aggregate ['sum :order/total]} [:order/id '_])
;; => {:query {:find [(sum ?order-total) .], :where [[?e :order/id] [?e :order/total ?order-total]]}}

(data->query ^{:aggregate :order/customer} [:order/id '_])
;; => {:query {:find [[?order-customer ...]], :where [[?e :order/id] [?e :order/customer ?order-customer]]}}
sourceraw docstring

excludeclj

(exclude q binding values & [input-name])
source

findclj

(find bindings)
(find q bindings & [override?])

Adds bindings to query :find

Adds bindings to query `:find`
sourceraw docstring

find-collclj

(find-coll binding)
(find-coll q binding)

Adds collection binding to query :find

Adds collection binding to query `:find`
sourceraw docstring

find-scalarclj

(find-scalar binding)
(find-scalar q binding)

Adds scalar binding to query :find

Adds scalar binding to query `:find`
sourceraw docstring

inclj

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

or-joinclj

(or-join q conditions & [values])
source

whereclj

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

where*clj

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

where->clj

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

where-missingclj

(where-missing q condition)

Adds missing? condition to query. Condition may have or may not have source binding, $ is used then

Adds `missing?` condition to query. Condition may have or may not have source binding, $ is used then
sourceraw docstring

where-notclj

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

where-not*clj

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

where?clj

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

withclj

(with q & bindings)

Adds with part to query

Adds `with` part to query
sourceraw docstring

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

× close