Ash.Query.Calculation (ash v3.37.0)

Copy Markdown View Source

Represents a calculated attribute requested on a query

Summary

Functions

Creates a new query calculation from a resource calculation.

Creates a new query calculation from a resource calculation, raising any errors.

Types

t()

@type t() :: %Ash.Query.Calculation{
  allow_nil?: term(),
  async?: term(),
  authorize?: term(),
  calc_name: term(),
  constraints: term(),
  context: term(),
  filterable?: term(),
  load: term(),
  module: term(),
  multitenancy: term(),
  name: term(),
  opts: term(),
  required_loads: term(),
  select: term(),
  sensitive?: term(),
  sortable?: term(),
  type: term()
}

Functions

from_resource_calculation(resource, name, opts \\ [])

Creates a new query calculation from a resource calculation.

Options

  • :args (map of term/0 keys and term/0 values) - Arguments to pass to the calculation, keyed by argument name as an atom or a string The default value is %{}.

  • :source_context (map/0) - Context from the source query or changeset. The default value is %{}.

  • :allow_expr? (boolean/0) - Whether arguments that allow expressions may be given expressions. The default value is true.

from_resource_calculation!(resource, name, opts \\ [])

Creates a new query calculation from a resource calculation, raising any errors.

See from_resource_calculation/3 for more.

new(name, module, calc_opts, type, constraints, opts \\ [])

Creates a new query calculation.

Options

  • :arguments (map/0) - Arguments to pass to the calculation The default value is %{}.

  • :async? (boolean/0) - Whether or not this calculation should be run asynchronously The default value is false.

  • :filterable? (boolean/0) - Whether or not this calculation can be filtered on The default value is true.

  • :sortable? (boolean/0) - Whether or not this calculation can be sorted on The default value is true.

  • :sensitive? (boolean/0) - Whether or not references to this calculation will be considered sensitive The default value is false.

  • :allow_nil? (boolean/0) - Whether or not the calculation can return nil. The default value is true.

  • :load (term/0) - Loads that are required for the calculation.

  • :actor (term/0) - The actor performing the calculation.

  • :tenant (term/0) - The tenant performing the calculation.

  • :authorize? (boolean/0) - Whether or not the related data that the calculation uses should be authorized, when the parent query is authorized. See the authorize? option on resource calculations for more. The default value is false.

  • :tracer (term/0) - The tracer or tracers used in the calculation.

  • :source_context (map/0) - Context from the source query or changeset. The default value is %{}.