workflo.macros.query

+query-fragment-registry+

bind-query-parameters

(bind-query-parameters query params)

Takes a parsed query and a map of named parameters and their values. Binds the unbound parameters in the query (that is, those where the value is either a symbol beginning with a ? or a vector of such symbols) to values of the corresponding parameters in the parameter map and returns the result.

As an example, the :db/id parameter in the query

[{:name user :type :join :join-target [{:name name :type :property}] :parameters {:db/id ?foo :user/friend [?bar ?baz]}}]

would be bound to the value 10 if the parameter map was {:foo 10 :bar {:baz :ruux}} and the :user/friend parameter would be bound to the value :ruux.

conform

(conform query)

conform-and-parse

(conform-and-parse query)

Conforms and parses a query expression like

[user [name :as nm email {friends User}] [current-user _]]

into a flat vector of parsed properties with the following structure:

[{:name user/name :type :property :alias nm}
 {:name user/email :type :property}
 {:name user/friends :type :join :join-target User}
 {:name current-user :type :link :link-id _}].

From this it is trivial to generate queries for arbitrary frameworks (e.g. Om Next) as well as keys for destructuring the results.

map-destructuring-keys

(map-destructuring-keys query)

Generates keys for destructuring a map of query results.

parse

(parse query)

parse-subquery

multimethod

Takes a subquery and returns a vector of parsed properties, each in one of the following forms:

{:name user/name :type :property :alias user-name}
{:name user/email :type :property}
{:name user/friends :type :join
 :join-source {name user/friends :type :property}
 :join-target User}
{:name user/friends :type :join
 :join-source {:name user/friends :type :property}
 :join-target [{:name user/name :type :property}]}
{:name current-user :type :link :link-id _}.

Each of these may in addition contain an optional :parameters key with a {symbol ?variable}-style map and an :alias key with a symbol to use when destructuring instead of the original name.

query-type

(query-type query)

register-query-fragment!

(register-query-fragment! name def)

registered-query-fragments

(registered-query-fragments)

reset-registered-query-fragments!

(reset-registered-query-fragments!)

resolve-query-fragment

(resolve-query-fragment name)

unregister-query-fragment!

(unregister-query-fragment! name)