ash v1.15.0 Ash.Query.Function behaviour View Source

A function is a predicate with an arguments list.

For more information on being a predicate, see Ash.Filter.Predicate. Most of the complexities are there. A function must meet both behaviours.

Link to this section Summary

Functions

Attaches the appropiate suffix to refer to an ordinal number, e.g 1 -> "1st"

Callbacks

The number and types of arguments supported.

Return true or false if the left and right match the operator.

Link to this section Types

Specs

arg() :: :ref | :term | {:options, Keyword.t()}

Link to this section Functions

Attaches the appropiate suffix to refer to an ordinal number, e.g 1 -> "1st"

Link to this section Callbacks

Specs

args() :: [arg()]

The number and types of arguments supported.

Currently supports three values: :ref, :term, and {:options, schema}.

  • :ref - a column/relationship path reference. Will be an instance of Ash.Filter.Ref
  • :term - any value. No type validation is currently supported except for what is listed here, so it must be done in the new/1 function
  • {:options, keys} - Only the last arg may be options, and keys is a list of atoms for which options are accepted

Specs

match?(term()) :: boolean()

Return true or false if the left and right match the operator.

Any references are resolved before being passed in.

If this is not defined, it will be assumed that data does not match.

Specs

new([term()]) :: {:ok, term()}