(->db-connection conn)Positional factory function for class sqlosure.db_connection.db-connection.
Positional factory function for class sqlosure.db_connection.db-connection.
(db-connection-conn db-connection)Access conn field (The database connection map as used by jdbc.) from a [[db-connection]] record. See sqlosure.db-connection/make-db-connection.
Access `conn` field (The database connection map as used by jdbc.) from a [[db-connection]] record. See [[sqlosure.db-connection/make-db-connection]].
(db-connection? thing)Is object a db-connection record? See sqlosure.db-connection/make-db-connection.
Is object a `db-connection` record? See [[sqlosure.db-connection/make-db-connection]].
(define-type-method-implementations ty set-parameter-fn get-parameter-fn)Conveniently define the set-parameter and get-parameter of a type
simultaniously.
Conveniently define the `set-parameter` and `get-parameter` of a type simultaniously.
(delete! conn sql-table criterion-proc)delete! takes a db-connection, a sql-table and a criterion function and
deletes all entries in sql-table that satisfy the criteria.
criterion-proc is a function that takes as many arguments as the relation
has fields. In it's body one can specify the criteria in the same manner as
in regular sqlosure queries.
Example:
(def db-spec { ... }) ;; Your db-connection map.
(def kv-table (table "kv" {"key" $integer-t
"value" $string-t}))
;; Delete all records where key > 10.
(delete! (db-connect db-spec) kv-table
(fn [k v]
($> k ($integer 10))))
`delete!` takes a db-connection, a sql-table and a criterion function and
deletes all entries in `sql-table` that satisfy the criteria.
`criterion-proc` is a function that takes as many arguments as the relation
has fields. In it's body one can specify the criteria in the same manner as
in regular sqlosure queries.
Example:
(def db-spec { ... }) ;; Your db-connection map.
(def kv-table (table "kv" {"key" $integer-t
"value" $string-t}))
;; Delete all records where key > 10.
(delete! (db-connect db-spec) kv-table
(fn [k v]
($> k ($integer 10))))Creates the type method ::get-from-result-set with a default get function
using .getObject on every input value and type.
Creates the type method `::get-from-result-set` with a default get function using `.getObject` on every input value and type.
(insert! conn sql-table & args)insert! takes a db-connection and an sql-table and some rest args and
attempts to insert them into the connected databases table.
The table to insert into is the relational-algebra/base-relation-handle of
sql-table.
args can either be:
Example:
(def db-spec { ... }) ;; Your db-connection map.
;; For inserts that contain every column of the specified table:
(insert! (db-connect db-spec) some-table arg1 arg2 ... argN)
;; For inserts that only specify a subset of all columns:
(insert! (db-connect db-spec) some-table
(alist->rel-scheme {"foo" $integer-t
"bar" $string-t}
integer-value string-value))
`insert!` takes a db-connection and an sql-table and some rest `args` and
attempts to insert them into the connected databases table.
The table to insert into is the `relational-algebra/base-relation-handle` of
`sql-table`.
`args` can either be:
- a set of values to insert if there is a value for each column. Those
must be in the order of the columns in the table.
- a rel-scheme, specifying the columns to insert the values into follwed
by the desired values.
Example:
(def db-spec { ... }) ;; Your db-connection map.
;; For inserts that contain every column of the specified table:
(insert! (db-connect db-spec) some-table arg1 arg2 ... argN)
;; For inserts that only specify a subset of all columns:
(insert! (db-connect db-spec) some-table
(alist->rel-scheme {"foo" $integer-t
"bar" $string-t}
integer-value string-value))(make-db-connection conn)Construct a db-connection (db-connection serves as a container for storing the current
db-connection as well as backend specific conversion and printer
functions.) record.
conn (The database connection map as used by jdbc.): access via sqlosure.db-connection/db-connection-conn
Construct a `db-connection` (`db-connection` serves as a container for storing the current
db-connection as well as backend specific conversion and printer
functions.) record.
`conn` (The database connection map as used by jdbc.): access via [[sqlosure.db-connection/db-connection-conn]](map->db-connection m__7585__auto__)Factory function for class sqlosure.db_connection.db-connection, taking a map of keywords to field values.
Factory function for class sqlosure.db_connection.db-connection, taking a map of keywords to field values.
(result-set-seq rs col-types)Creates and returns a lazy sequence of maps corresponding to the rows in the java.sql.ResultSet rs.
Creates and returns a lazy sequence of maps corresponding to the rows in the java.sql.ResultSet rs.
(run-query conn q & {:keys [optimize?] :or {optimize? true} :as opts-map})Takes a database connection and a query and runs it against the database.
Example:
(def db-spec { ... }) ;; Your db-connection map.
(def kv-table (table "kv" {"key" $integer-t
"value" $string-t}))
;; Get all records from kv-table where "key" is less than 10.
(run-query (db-connect db-spec)
(query [kv (<- kv-table)]
(restrict ($> (! k "key")
($integer 10)))
(project {"value" (! kv "value")})))
Takes a database connection and a query and runs it against the database.
Example:
(def db-spec { ... }) ;; Your db-connection map.
(def kv-table (table "kv" {"key" $integer-t
"value" $string-t}))
;; Get all records from kv-table where "key" is less than 10.
(run-query (db-connect db-spec)
(query [kv (<- kv-table)]
(restrict ($> (! k "key")
($integer 10)))
(project {"value" (! kv "value")})))Creates the type method ::set-parameter with a default set function
using .setObject on every input value and type.
Creates the type method `::set-parameter` with a default set function using `.setObject` on every input value and type.
(update! conn sql-table criterion-proc alist-first & args)update! takes a db-connection, a sql-table, a criterion-proc and and map
and updates all entries of sql-table that satisfy criterion-proc with the
new key->value pairs specified in alist-first function.
Example:
(def db-spec { ... }) ;; Your db-connection map.
(def kv-table (table "kv" {"key" $integer-t
"value" $string-t}))
;; Update the "value" field all records where key > 10 to "NEWVAL".
(update! (db-connect db-spec) kv-table
(fn [k v]
($> k ($integer 10))) ;; Read: "key" > 10
(fn [k v]
{"value" ($string "NEWVAL")})
`update!` takes a db-connection, a sql-table, a criterion-proc and and map
and updates all entries of `sql-table` that satisfy `criterion-proc` with the
new key->value pairs specified in `alist-first` function.
Example:
(def db-spec { ... }) ;; Your db-connection map.
(def kv-table (table "kv" {"key" $integer-t
"value" $string-t}))
;; Update the "value" field all records where key > 10 to "NEWVAL".
(update! (db-connect db-spec) kv-table
(fn [k v]
($> k ($integer 10))) ;; Read: "key" > 10
(fn [k v]
{"value" ($string "NEWVAL")})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 |