Liking cljdoc? Tell your friends :D

stowaway.sql


apply-criteriaclj

(apply-criteria sql criteria)
(apply-criteria sql criteria options)

Adds a WHERE clause to a sql map based on the specified criteria.

The criteria can be a map, which will result in a set of conditions joined by AND.

(apply-criteria {:first-name "John" :last-name "Doe"}) => {:where [:and [:= :first_name "Jone"] [:= :last_name "Doe"]]}

Maps can be joined with OR logic also. [:or {:first-name "John"} {:last-name "Doe"}] => {:where [:or [:= :first_name "John"] [:= :last_name "Doe"]]}

Related tables can be included in a query by passing a :relationships map in the options and including a compound key in the criteria.

(apply-criteria {[:user :last-name] "Doe"} {:target :order :relationships {#{:user :order} {:primary-table :users :foreign-table :orders :foreign-id :user_id}}}) => {:where [:= :users.last_name "Doe"] :from :orders :join [:users [:= :users.id :orders.user_id]]} If a table name does not match the key used to identify the model type, it will first be looked up from the :table-names map in options. Otherwise, an attempt will be made to make it plural.

Adds a WHERE clause to a sql map based on the specified criteria.

The criteria can be a map, which will result in a set of conditions
joined by AND.

(apply-criteria {:first-name "John" :last-name "Doe"}) => {:where [:and [:= :first_name "Jone"] [:= :last_name "Doe"]]}

Maps can be joined with OR logic also.
[:or {:first-name "John"} {:last-name "Doe"}] => {:where [:or [:= :first_name "John"] [:= :last_name "Doe"]]}

Related tables can be included in a query by passing a :relationships
map in the options and including a compound key in the criteria.

(apply-criteria {[:user :last-name] "Doe"}
                {:target :order
                :relationships {#{:user :order} {:primary-table :users
                                                 :foreign-table :orders
                                                 :foreign-id :user_id}}}) => {:where [:= :users.last_name "Doe"]
                                                                              :from :orders
                                                                              :join [:users [:= :users.id :orders.user_id]]}
If a table name does not match the key used to identify the model type, it will
first be looked up from the :table-names map in options. Otherwise, an attempt
will be made to make it plural.
sourceraw docstring

apply-limitclj

(apply-limit sql options)
source

apply-offsetclj

(apply-offset sql options)
source

apply-sortclj

(apply-sort sql {:keys [sort]})
source

deep-contains?clj

(deep-contains? data k)

Returns a boolean value indicating whether or not a field is specified in a criteria structure.

(deep-contains? {:first-name "John"} :first-name) => true (deep-contains? {:last-name "Doe"} :first-name) => false (deep-contains? [:or {:first-name "John"} {:last-name "Doe"}] :first-name) => true

Returns a boolean value indicating whether or not a field
is specified in a criteria structure.

(deep-contains? {:first-name "John"} :first-name) => true
(deep-contains? {:last-name "Doe"} :first-name) => false
(deep-contains? [:or {:first-name "John"} {:last-name "Doe"}] :first-name) => true
sourceraw docstring

deep-dissoccljmultimethod

Removes a value from a criteria structure.

(deep-dissoc [:or {:first-name "John"} {:last-name "Doe"}] :first-name) => {:last-name "Doe"}

Removes a value from a criteria structure.

(deep-dissoc [:or {:first-name "John"} {:last-name "Doe"}] :first-name) => {:last-name "Doe"}
sourceraw docstring

deep-getclj

(deep-get data k)

Returns the value specified for a field within a criteria structure.

(deep-get {:first-name "John"} :first-name) => "John" (deep-get {:last-name "Doe"} :first-name) => nil (deep-get [:or {:first-name "John"} {:last-name "Doe"}] :first-name) => "John"

Returns the value specified for a field within a criteria structure.

(deep-get {:first-name "John"} :first-name) => "John"
(deep-get {:last-name "Doe"} :first-name) => nil
(deep-get [:or {:first-name "John"} {:last-name "Doe"}] :first-name) => "John"
sourceraw docstring

deep-update-in-ifclj

(deep-update-in-if data k f)
source

delimitcljmultimethod

source

ensure-joinclj

(ensure-join sql table criteria)

Ensures that the specified sql map contains the specified join clause

Ensures that the specified sql map contains the specified join clause
sourceraw docstring

get-intclj

(get-int m k)
source

map->wherecljmultimethod

source

select-countclj

(select-count sql {:keys [count]})
source

update-in-ifclj

(update-in-if m k-path f)
source

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

× close