Ash.Expr (ash v3.24.1)

Copy Markdown View Source

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 types for a given operator or function module and its 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

t()

@type t() :: any()

Functions

actor(value)

A template helper for using actor values in filter templates

arg(name)

A template helper for using action arguments in filter templates

atomic_ref(expr)

A template helper for referring to the most recent atomic expression applied to an update field

calc(expression, opts \\ [])

(macro)
@spec calc(Macro.t(), opts :: Keyword.t()) :: t()

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})
])

can_return_nil?(pred)

combinations(name)

A template helper for creating a reference

context(name)

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.

determine_type(value)

determine_types(mod, args, returns \\ nil, nested? \\ false)

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).

eval(expression, opts \\ [])

Evaluate an expression. This function only works if you have no references, or if you provide the record option.

eval!(expression, opts \\ [])

Evaluate an expression. See eval/2 for more.

expr(body)

(macro)
@spec expr(Macro.t()) :: t()

Creates an expression. See the Expressions guide for more.

expr?(value)

@spec expr?(term()) :: boolean()

Returns true if the value is or contains an expression

or_where(left, right)

(macro)
@spec or_where(Macro.t(), Macro.t()) :: t()

parent(expr)

A template helper for creating a parent reference

ref(name)

A template helper for creating a reference

ref(path, name)

A template helper for creating a reference to a related path

template_references?(list, pred)

Whether or not a given template contains an actor reference

template_references_argument?(template)

template_references_context?(template)

tenant()

A template helper for using the tenant in filter templates

to_sat_expression(resource, expression)

Prepares a filter for comparison

where(left, right)

(macro)
@spec where(Macro.t(), Macro.t()) :: t()