(as-query db args)(as-statement db args)(build-types type-map table-naming column-naming)(build-types type-registry type-map table-naming column-naming)(-get-connection _)(-with-connection _ task-fn)(create-insert-sql {:keys [types column-naming table-naming] :as db}
{:keys [table columns returning] :as spec})(create-update-sql {:keys [types table-naming column-naming] :as db}
{:keys [table columns where where-params] :as spec})(defquery name sql & kv)(edn-type)(edn-type edn-opts)(execute db stmt)(execute db stmt params)(get-connection db)(insert db spec data)(insert-one db stmt data)(insert-one! db table data)(insert-one! db table data return-column)shorthand for insert-one, but potential DANGER!
don't use with maps you got from an untrusted source will insert all values contained in the data map
if you expect {:user "name" :password "me"} but the user sends you {:user "name" :password "me" :admin true} you might run into trouble
use insert-one and specify {:columns [:user :password]} if you want to be safe.
(sql/insert-one! db :table data) returns nil (sql/insert-one! db :table data :id) returns the id of the inserted row (sql/insert-one! db :table data [:id]) returns the data merged with the resulting map {:id ...}
shorthand for insert-one, but potential DANGER!
don't use with maps you got from an untrusted source
will insert all values contained in the data map
if you expect
{:user "name" :password "me"}
but the user sends you
{:user "name" :password "me" :admin true}
you might run into trouble
use insert-one and specify {:columns [:user :password]} if you want to be safe.
(sql/insert-one! db :table data) returns nil
(sql/insert-one! db :table data :id) returns the id of the inserted row
(sql/insert-one! db :table data [:id]) returns the data merged with the resulting map {:id ...}
stores keywords without leading ":"
stores keywords without leading ":"
(from-sql-name this string)(to-sql-name this value)(now)(prepare db stmt)(prepare-insert db spec)(prepare-query db stmt)(prepare-update db spec)(query db q)(query db query params)(result->map key-fn)(result->map key-fn value-fn)(result->map key-fn value-fn init){:sql "SELECT * FROM something" :result (sql/result->map :id)}
will return {id1 row1, id2 row2, ...}
{:sql "SELECT key, value FROM something" :result (sql/result->map :key :value)}
returns {key1 value1, key2, value2, ...}
{:sql "SELECT * FROM something"
:result (sql/result->map :id)}
will return {id1 row1, id2 row2, ...}
{:sql "SELECT key, value FROM something"
:result (sql/result->map :key :value)}
returns {key1 value1, key2, value2, ...}(row->map-transform transform-fn)returns row as map after calling (transform-fn map)
returns row as map after calling (transform-fn map)
row is returned as the value of the first (only) column
row is returned as the value of the first (only) column
(set-type item-type)(set-type item-type requires-quoting)(start {:keys [host port user database ssl ssl-context ssl-verify-hostname
auth-handler connect-params connect-timeout-ms no-schema pool
table-naming column-naming types metric-registry
metric-collector]
:or {host "localhost"
port 5432
table-naming (DefaultNaming.)
column-naming (DefaultNaming.)
types TypeRegistry/DEFAULT}
:as opts})(stop db)(update! db table data)(update! {:keys [table-naming column-naming types] :as db}
table
data
where
params)(sql/update! db :table {:column value, ...} "id = $1" [id]) this is also potentially dangerous since all columns are updated
(sql/update! db :table {:column value, ...} "id = $1" [id])
this is also potentially dangerous since all columns are updated(vec-type item-type)(vec-type item-type requires-quoting)(with-connection db & body)(with-dashes x)(with-default-types db & handlers)(with-transaction db & body)(with-types {:keys [table-naming column-naming] :as db} type-map)copy db instance with custom type handlers {table-name {column-name type-handler}} types can also be declared per query
copy db instance with custom type handlers {table-name {column-name type-handler}}
types can also be declared per query(with-underscores x)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 |