(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})(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 the inserted data (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 the inserted data
(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)(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
(start {:keys [host port user database 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})(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(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 querycljdoc 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 |