Implementation of queries.
A query is a function which can extract k v from data.
Implementation of queries. A query is a function which can extract k v from data.
(accept f-conj x k v)General acceptor function design: when k is nil, means there is no match, current progress should fail; when v is nil, means there is no value.
f-conj, takes two argements, coll and a k-v pairx is the collection willing to acceptGeneral acceptor function design: when k is nil, means there is no match, current progress should fail; when v is nil, means there is no value. - funcition `f-conj`, takes two argements, coll and a k-v pair - `x` is the collection willing to accept
create a post processor by ::pp-type, returns a function takes k-v pair, returns the same shape of data
create a post processor by ::pp-type, returns a function takes k-v pair, returns the same shape of data
(assert-arg! pred arg)an error that represent apply-post illegal argument
an error that represent apply-post illegal argument
(data-error! reason k data)throw an exception specify data error
throw an exception specify data error
(filter-query q pred)returns a filter query which will not appears in result data, but will
void other query if in a vector query, pred is the filter condition
returns a filter query which will not appears in result data, but will void other query if in a vector query, `pred` is the filter condition
(fn-query k)(fn-query k f)returns a simple query has key as k, f to return a value from a map,
and child query to execute if matches.
returns a simple query has key as `k`, `f` to return a value from a map, and `child` query to execute if matches.
common acceptor using an empty map to accept
common acceptor using an empty map to accept
(mk-named-var-query t-sym-table sym)(mk-named-var-query t-sym-table status sym)returns a factory function which take a query q as its argument.
returns a factory function which take a query `q` as its argument.
(named-var-factory)returns a function takes a symbol as the argument, returns a named-var-query
returns a function takes a symbol as the argument, returns a named-var-query
(post-process-query child f-post-process)A query decorator post process its result
A query decorator post process its result
(pq id acceptor val-getter)construct a general query:
id key of this queryacceptor default acceptor of this query, used when no acceptor specified when invokeval-getter is the function to extract dataconstruct a general query: - `id` key of this query - `acceptor` default acceptor of this query, used when no acceptor specified when invoke - `val-getter` is the function to extract data
(run-bind f-query data)f-query takes a function (returned by named-var-factory) as argument,
returns a query, then run it on data, finally returns a vector:
`f-query` takes a function (returned by `named-var-factory`) as argument, returns a query, then run it on `data`, finally returns a vector: - query result - named variable binding map
(run-query q data)run a query q on data, returns the query result function.
A query result function has one argument of acceptor, which is another function takes k, v as arguments. The acceptor can be nil, means that the query are free to construct the result.
run a query `q` on `data`, returns the query result function. A query result function has one argument of acceptor, which is another function takes k, v as arguments. The acceptor can be nil, means that the query are free to construct the result.
(seq-query qr)returns a seq-query which applies query q to data (must be a collection) and return
returns a seq-query which applies query `q` to data (must be a collection) and return
(val-acceptor _ v)identity acceptor, ignore k, only return v
identity acceptor, ignore k, only return `v`
(vector-query queries)returns a vector query, takes other queries as its children,
then apply them to data, return the merged map.
returns a vector query, takes other `queries` as its children, then apply them to data, return the merged map.
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 |