Liking cljdoc? Tell your friends :D

workflo.macros.bind


binding-pathsclj

(binding-paths query)

Returns a vector of all property binding paths for a query or parsed query.

Returns a vector of all property binding paths for a query
or parsed query.
sourceraw docstring

path-bindingsclj

(path-bindings [leaf & path])

Takes a property binding path and returns destructuring map that can be used in combination with e.g. let to pluck the value of the corresponding property from a query result and bind it to the name of the property.

E.g. for a property path (a b/c d) (simplified notation with only the property names), it would return {{{a :a} :b/c} :d}, allowing to destructure a map like {:d {:b/c {:a <val>}}} and bind a to <val>.

It treats backref properties like _b/c in joins special by binding to b instead of c (the regular case) or _b.

Takes a property binding path and returns destructuring map
that can be used in combination with e.g. let to pluck the
value of the corresponding property from a query result
and bind it to the name of the property.

E.g. for a property path (a b/c d) (simplified notation with
only the property names), it would return {{{a :a} :b/c} :d},
allowing to destructure a map like {:d {:b/c {:a <val>}}}
and bind a to <val>.

It treats backref properties like _b/c in joins special by
binding to b instead of c (the regular case) or _b.
sourceraw docstring

property-binding-pathsclj

(property-binding-paths property)
(property-binding-paths property path)

Takes a property and an optional path of parents. Returns a flat vector of all paths inside the property and its parents. Each path is again a sequence of properties, starting from the leaf (e.g. a regular property) and ending at the root of the query.

As an example, the query [{user [user [name email]]]}] would result in the query AST

[{:name user :type :join
  :join-source {:name user :type :property}
  :join-target [{:name user/name :type :property}
                {:name user/email :type :property}]}].

Calling property-binding-paths with the join property would result in two paths, one for user -> user/name and one for user -> user/email:

[({:name user/name :type :property} {:name user :type :join :join-source ... :join-target ...}) ({:name user/email :type :property} {:name user :type :join :join-source ... :join-target ...})].

Takes a property and an optional path of parents. Returns
a flat vector of all paths inside the property and its
parents. Each path is again a sequence of properties,
starting from the leaf (e.g. a regular property) and
ending at the root of the query.

As an example, the query [{user [user [name email]]]}]
would result in the query AST

    [{:name user :type :join
      :join-source {:name user :type :property}
      :join-target [{:name user/name :type :property}
                    {:name user/email :type :property}]}].

Calling property-binding-paths with the join property
would result in two paths, one for user -> user/name and
one for user -> user/email:

  [({:name user/name :type :property}
    {:name user :type :join :join-source ... :join-target ...})
   ({:name user/email :type :property}
    {:name user :type :join :join-source ... :join-target ...})].
sourceraw docstring

query-bindingsclj

(query-bindings query)

Takes a query or parsed query and returns map bindings to be applied to the corresponding query result in order to destructure and bind all possible properties in the query result to their names.

E.g. for a query [a :as b c [d e {f [g :as h]}]] it would return {b :a, d :c/d, e :c/e, f :f, {{h :g} :f}}.

Takes a query or parsed query and returns map bindings to
be applied to the corresponding query result in order to
destructure and bind all possible properties in the query
result to their names.

E.g. for a query [a :as b c [d e {f [g :as h]}]] it
would return {b :a, d :c/d, e :c/e, f :f, {{h :g} :f}}.
sourceraw docstring

simplified-nameclj

(simplified-name sym-or-kw)
source

with-query-bindingsclj/smacro

(with-query-bindings query result & body)

Takes a query, a query result and an arbitrary code block. Wraps the code block so that all possible bindings derived from the query are bound to the values in the query result.

Takes a query, a query result and an arbitrary code block.
Wraps the code block so that all possible bindings derived
from the query are bound to the values in the query result.
sourceraw docstring

with-query-bindings*clj

(with-query-bindings* query result body)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close