#
View Source Ash.Calculation behaviour (ash v2.6.31)

The behaviour for a calculation module

Use `select/2` to apply a select statement when the calculation is loaded. This does not apply in the case that you are loading on existing resources using `MyApi.load`. It also doesn't apply when the calculation is used in a filter or sort, because it is not necessary to select fields to power filters done in the data layer.

# Link to this section Summary

## Callbacks

calculate(list, t, map)
describe(t)
expression(t, map)
init(t)
load(t, t, map)
select(t, t, map)

# Link to this section Callbacks

Link to this callback

# calculate(list, t, map)

View Source (optional)

    @callback calculate([Ash.Resource.record()], Keyword.t(), map()) ::
      {:ok, [term()]} | [term()] | {:error, term()} | :unknown

Link to this callback

# describe(t)

View Source

    @callback describe(Keyword.t()) :: String.t()

Link to this callback

# expression(t, map)

View Source (optional)

    @callback expression(Keyword.t(), map()) :: any()

Link to this callback

# init(t)

View Source

    @callback init(Keyword.t()) :: {:ok, Keyword.t()} | {:error, term()}

Link to this callback

# load(t, t, map)

View Source

    @callback load(Ash.Query.t(), Keyword.t(), map()) :: atom() | [atom()] | Keyword.t()

Link to this callback

# select(t, t, map)

View Source

    @callback select(Ash.Query.t(), Keyword.t(), map()) :: [atom()]