Tools to build Ash expressions
Summary
Functions
A template helper for using actor values in filter templates
A template helper for using action arguments in filter templates
A template helper for referring to the most recent atomic expression applied to an update field
Creates an expression calculation for use in sort and distinct statements.
A template helper for creating a reference
A template helper for using query context in filter templates
Determines the type of an expression, as {:ok, {type, constraints}}, or :error if
it can't be determined.
Determines the type of an expression like determine_type/1, along with the type of
every operand it was resolved from, and theirs, and so on.
Determines the types for a given operator or function module and its arguments.
Determines the types for an operator or function module and its arguments, like
determine_types/4, given the types of the arguments.
Evaluate an expression. This function only works if you have no references, or if you provide the record option.
Evaluate an expression. See eval/2 for more.
Creates an expression. See the Expressions guide for more.
Returns true if the value is or contains an expression
A template helper for creating a parent reference
A template helper for creating a reference
A template helper for creating a reference to a related path
Whether or not a given template contains an actor reference
A template helper for using the tenant in filter templates
Prepares a filter for comparison
Types
@type t() :: any()
Functions
A template helper for using actor values in filter templates
A template helper for using action arguments in filter templates
A template helper for referring to the most recent atomic expression applied to an update field
Creates an expression calculation for use in sort and distinct statements.
Examples
Ash.Query.sort(query, [
{calc(string_upcase(name), :asc},
{calc(count_nils([field1, field2]), type: :integer), :desc})
])
A template helper for creating a reference
A template helper for using query context in filter templates
An atom will get the value for a key, and a list will be accessed via get_in.
Determines the type of an expression, as {:ok, {type, constraints}}, or :error if
it can't be determined.
The type of an operator or function call is resolved from the types of its operands, so this walks the whole expression below it.
@spec determine_type_tree(term()) :: Ash.Expr.TypeTree.t()
Determines the type of an expression like determine_type/1, along with the type of
every operand it was resolved from, and theirs, and so on.
Takes time linear in the size of the expression. See
determine_types_with_operand_types/4 for what it is for.
Determines the types for a given operator or function module and its arguments.
Given an operator or function module (e.g. Ash.Query.Operator.In), resolves the
concrete types of the arguments based on the module's declared type signatures and
any registered operator overloads. Returns {resolved_types, return_type} where
resolved_types is a list of {type, constraints} tuples (or nil for unresolvable
arguments) and return_type is the resolved return type.
This is the primary type resolution mechanism used by data layer expression compilers.
It performs actual type validation including coercion checks, unlike
Ash.Type.determine_types/2 which only resolves vague types (:same/:any).
@spec determine_types_with_operand_types( module(), [term()], [{:ok, {Ash.Type.t(), Keyword.t()}} | :error], term() ) :: {[{Ash.Type.t(), Keyword.t()} | nil], {Ash.Type.t(), Keyword.t()} | nil}
Determines the types for an operator or function module and its arguments, like
determine_types/4, given the types of the arguments.
operand_types has one entry per argument, as determine_type/1 returns it for that
argument: {:ok, {type, constraints}} or :error. determine_types/4 works these out
itself, by walking each argument's whole subtree. A caller that types an expression
top down, calling this at every node (as a data layer compiling an expression does),
would repeat that walk for each level above a node and so take time proportional to
the size of the tree times its depth. Instead, it can type the tree once with
determine_type_tree/1, and at each node pass the types of its operands from there.
Evaluate an expression. This function only works if you have no references, or if you provide the record option.
Evaluate an expression. See eval/2 for more.
Creates an expression. See the Expressions guide for more.
Returns true if the value is or contains an expression
A template helper for creating a parent reference
A template helper for creating a reference
A template helper for creating a reference to a related path
Whether or not a given template contains an actor reference
A template helper for using the tenant in filter templates
Prepares a filter for comparison