#
View Source Ash.Resource.Preparation behaviour (ash v2.14.2)

The behaviour for an action-specific query preparation.

`init/1` is defined automatically by `use Ash.Resource.Preparation`, but can be implemented if you want to validate/transform any options passed to the module.

The main function is `prepare/3`. It takes the changeset, any options that were provided when this change was configured on a resource, and the context, which currently only has the actor.

To access any query arguments from within a preparation, make sure you are using `Ash.Query.get_argument/2` as the argument keys may be strings or atoms.

# Link to this section Summary

## Types

context()
ref()
t()

## Callbacks

init(t)
prepare(query, t, context)

# Link to this section Types

Link to this type

# context()

View Source

    @type context() :: %{
      optional(:actor) => Ash.Resource.record(),
      optional(any()) => any()
    }

Link to this type

# ref()

View Source

    @type ref() :: {module(), Keyword.t()} | module()

Link to this type

# t()

View Source

    @type t() :: %Ash.Resource.Preparation{preparation: term()}

# Link to this section Callbacks

Link to this callback

# init(t)

View Source

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

Link to this callback

# prepare(query, t, context)

View Source

    @callback prepare(query, Keyword.t(), context()) :: query when query: struct()