(args-spec query-type model)
[[clojure.spec.alpha]] spec that should be used to parse unparsed args for query-type
by the default implementation
of parse-args
.
[[clojure.spec.alpha]] spec that should be used to parse unparsed args for `query-type` by the default implementation of [[parse-args]].
(build query-type model {:keys [query] :as parsed-args})
build
takes the parsed args returned by [[parse]] and builds them into a query that can be compiled
by toucan2.compile/with-compiled-query
. For the default implementations, build
takes the parsed arguments and
builds a Honey SQL 2 map. Dispatches on query-type
, model
, and the :query
in parsed-args
.
`build` takes the parsed args returned by [[parse]] and builds them into a query that can be compiled by [[toucan2.compile/with-compiled-query]]. For the default implementations, `build` takes the parsed arguments and builds a Honey SQL 2 map. Dispatches on `query-type`, `model`, and the `:query` in `parsed-args`.
(do-with-query model queryable f)
Impls should resolve queryable
to a query and call
(f query)
Impls should resolve `queryable` to a query and call (f query)
(parse-args query-type model unparsed-args)
(parse-args query-type model unparsed-args)
parse-args
takes a sequence of unparsed args passed to something like toucan2.select/select
(excluding the
modelable
arg, which has to be resolved to a model
first in order for this to be able to dispatch), and parses
them into a parsed args map. The default implementation uses [[clojure.spec.alpha]] to parse the args according to
the args-spec
for query-type
and model
.
These keys are commonly returned by several of the different implementations parse-args
, and other tooling is
build to leverage them:
:queryable
-- something that can be resolved to a query with with-query
, for example a map or integer or
'named query' keyword. The resolved query is ultimately combined with other parsed args and built into something like
a Honey SQL map with build
, then compiled with toucan2.compile/with-compiled-query
.
:kv-args
-- map of key-value pairs. When build
builds a query, it calls apply-kv-arg
for each of the
key-value pairs. The default behavior is to append a Honey SQL :where
clause based on the pair; but you can
customize the behavior for specific keywords to do other things -- :toucan/pk
is one such example.
:columns
-- for things that return instances, :columns
is a sequence of columns to return. These are commonly
specified by wrapping the modelable in a [modelable & columns]
vector.
`parse-args` takes a sequence of unparsed args passed to something like [[toucan2.select/select]] (excluding the `modelable` arg, which has to be resolved to a `model` first in order for this to be able to dispatch), and parses them into a parsed args map. The default implementation uses [[clojure.spec.alpha]] to parse the args according to the [[args-spec]] for `query-type` and `model`. These keys are commonly returned by several of the different implementations `parse-args`, and other tooling is build to leverage them: * `:queryable` -- something that can be resolved to a query with [[with-query]], for example a map or integer or 'named query' keyword. The resolved query is ultimately combined with other parsed args and built into something like a Honey SQL map with [[build]], then compiled with [[toucan2.compile/with-compiled-query]]. * `:kv-args` -- map of key-value pairs. When [[build]] builds a query, it calls [[apply-kv-arg]] for each of the key-value pairs. The default behavior is to append a Honey SQL `:where` clause based on the pair; but you can customize the behavior for specific keywords to do other things -- `:toucan/pk` is one such example. * `:columns` -- for things that return instances, `:columns` is a sequence of columns to return. These are commonly specified by wrapping the modelable in a `[modelable & columns]` vector.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close