Liking cljdoc? Tell your friends :D

sql-file.middleware

A current database connection for a body of code, opened only when something first uses it.

with-db-connection (and wrap-db-connection, for a Ring-style handler) makes a database available to its body without opening a connection. The connection is opened the first time current-db-connection is called (by a query, a transaction, or anything else that needs it), kept for the rest of the body, and closed (returned to its pool, for a pooled database) when the body ends. A body that never uses the database never opens a connection.

A current database connection for a body of code, opened only when
something first uses it.

with-db-connection (and wrap-db-connection, for a Ring-style handler)
makes a database available to its body without opening a
connection. The connection is opened the first time
current-db-connection is called (by a query, a transaction, or
anything else that needs it), kept for the rest of the body, and
closed (returned to its pool, for a pooled database) when the body
ends. A body that never uses the database never opens a connection.
raw docstring

sql-file.queries

sql-file's queries against its own tables. These take the connection explicitly, as a :connection call option, since sql-file's functions are given the connection to use.

sql-file's queries against its own tables. These take the
connection explicitly, as a :connection call option, since
sql-file's functions are given the connection to use.
raw docstring

sql-file.query-cache

A cache of query results, as yesql query middleware.

A query is cached by giving it a cache-name info value: a vector of strings and keywords, where each keyword is replaced by the query argument of that name. A query's results are cached under that name (and the query name and arguments), and another query can clear everything cached under a name with invalidate-cache-names:

-- name: get-items-by-list
-- info-cache-name: ["list" :list_id]
SELECT * FROM item WHERE list_id = :list_id

-- name: add-item!
-- info-invalidate-cache-names: [["list" :list_id]]
INSERT INTO item (list_id, title) VALUES (:list_id, :title)

The cache itself is an atom, made by make-query-cache, that queries use only while it's bound with with-query-cache (or call-with-query-cache). With no cache bound, queries run uncached.

A cache of query results, as yesql query middleware.

A query is cached by giving it a cache-name info value: a vector of
strings and keywords, where each keyword is replaced by the query
argument of that name. A query's results are cached under that name
(and the query name and arguments), and another query can clear
everything cached under a name with invalidate-cache-names:

    -- name: get-items-by-list
    -- info-cache-name: ["list" :list_id]
    SELECT * FROM item WHERE list_id = :list_id

    -- name: add-item!
    -- info-invalidate-cache-names: [["list" :list_id]]
    INSERT INTO item (list_id, title) VALUES (:list_id, :title)

The cache itself is an atom, made by make-query-cache, that queries
use only while it's bound with with-query-cache (or
call-with-query-cache). With no cache bound, queries run uncached.
raw docstring

sql-file.query-middleware

yesql query middleware for databases managed by sql-file.

Queries may declare how their results are returned with a query-mode info value in the query file:

-- name: count-points
-- info-query-mode: :scalar
SELECT COUNT(*) FROM point

The modes are :direct (the default: the rows as returned), :scalar (the single value of a single-column result, or nil), :row (the first row, or nil) and :column (the values of a single-column result).

yesql query middleware for databases managed by sql-file.

Queries may declare how their results are returned with a
query-mode info value in the query file:

    -- name: count-points
    -- info-query-mode: :scalar
    SELECT COUNT(*) FROM point

The modes are :direct (the default: the rows as returned), :scalar
(the single value of a single-column result, or nil), :row (the
first row, or nil) and :column (the values of a single-column
result).
raw docstring

sql-file.script

Utility functions for processing SQL scripts.

Utility functions for processing SQL scripts.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close