ash v0.10.0 Ash.DataLayer behaviour View Source

The interface for being an ash data layer.

This is a large behaviour, and this capability is not complete, but the idea is to have a large amount of optional callbacks, and use the can?/2 callback to ensure that the engine only ever tries to interact with the data layer in ways that it supports.

Link to this section Summary

Link to this section Types

Specs

feature() ::
  :transact
  | :boolean_filter
  | :async_engine
  | :join
  | :transact
  | {:filter_predicate, Ash.Type.t(), struct()}
  | {:sort, Ash.Type.t()}
  | :upsert
  | :composite_primary_key

Link to this section Functions

Specs

can?(feature(), Ash.resource()) :: boolean()
Link to this function

create(resource, changeset)

View Source

Specs

create(Ash.resource(), Ecto.Changeset.t()) ::
  {:ok, Ash.record()} | {:error, term()}
Link to this function

custom_filters(resource)

View Source
Link to this function

filter(query, filter, resource)

View Source

Specs

filter(Ash.data_layer_query(), Ash.filter(), Ash.resource()) ::
  {:ok, Ash.data_layer_query()} | {:error, term()}
Link to this function

limit(query, limit, resource)

View Source

Specs

limit(Ash.data_layer_query(), limit :: non_neg_integer(), Ash.resource()) ::
  {:ok, Ash.data_layer_query()} | {:error, term()}
Link to this function

offset(query, offset, resource)

View Source

Specs

offset(Ash.data_layer_query(), offset :: non_neg_integer(), Ash.resource()) ::
  {:ok, Ash.data_layer_query()} | {:error, term()}
Link to this function

resource_to_query(resource)

View Source

Specs

resource_to_query(Ash.resource()) :: Ash.data_layer_query()
Link to this function

run_query(query, central_resource)

View Source

Specs

run_query(Ash.data_layer_query(), central_resource :: Ash.resource()) ::
  {:ok, [Ash.record()]} | {:error, term()}
Link to this function

sort(query, sort, resource)

View Source

Specs

sort(Ash.data_layer_query(), Ash.sort(), Ash.resource()) ::
  {:ok, Ash.data_layer_query()} | {:error, term()}
Link to this function

transact(resource, func)

View Source
Link to this function

update(resource, changeset)

View Source

Specs

update(Ash.resource(), Ecto.Changeset.t()) ::
  {:ok, Ash.record()} | {:error, term()}
Link to this function

upsert(resource, changeset)

View Source

Specs

upsert(Ash.resource(), Ecto.Changeset.t()) ::
  {:ok, Ash.record()} | {:error, term()}

Link to this section Callbacks

Specs

can?(Ash.resource(), feature()) :: boolean()

Specs

create(Ash.resource(), changeset :: Ecto.Changeset.t()) ::
  {:ok, Ash.resource()} | {:error, term()}
Link to this callback

custom_filters(arg1)

View Source (optional)

Specs

custom_filters(Ash.resource()) :: map()

Specs

destroy(record :: Ash.record()) :: :ok | {:error, term()}
Link to this callback

filter(arg1, arg2, resource)

View Source

Specs

filter(Ash.data_layer_query(), Ash.filter(), resource :: Ash.resource()) ::
  {:ok, Ash.data_layer_query()} | {:error, term()}
Link to this callback

in_transaction?(arg1)

View Source (optional)

Specs

in_transaction?(Ash.resource()) :: boolean()
Link to this callback

limit(arg1, limit, resource)

View Source

Specs

limit(
  Ash.data_layer_query(),
  limit :: non_neg_integer(),
  resource :: Ash.resource()
) :: {:ok, Ash.data_layer_query()} | {:error, term()}
Link to this callback

offset(arg1, offset, resource)

View Source

Specs

offset(
  Ash.data_layer_query(),
  offset :: non_neg_integer(),
  resource :: Ash.resource()
) :: {:ok, Ash.data_layer_query()} | {:error, term()}

Specs

resource_to_query(Ash.resource()) :: Ash.data_layer_query()
Link to this callback

rollback(arg1, term)

View Source (optional)

Specs

rollback(Ash.resource(), term()) :: no_return()

Specs

run_query(Ash.data_layer_query(), Ash.resource()) ::
  {:ok, [Ash.resource()]} | {:error, term()}
Link to this callback

sort(arg1, arg2, resource)

View Source

Specs

sort(Ash.data_layer_query(), Ash.sort(), resource :: Ash.resource()) ::
  {:ok, Ash.data_layer_query()} | {:error, term()}
Link to this callback

transaction(arg1, function)

View Source (optional)

Specs

transaction(Ash.resource(), (() -> term())) :: {:ok, term()} | {:error, term()}

Specs

update(Ash.resource(), changeset :: Ecto.Changeset.t()) ::
  {:ok, Ash.resource()} | {:error, term()}
Link to this callback

upsert(arg1, changeset)

View Source (optional)

Specs

upsert(Ash.resource(), changeset :: Ecto.Changeset.t()) ::
  {:ok, Ash.resource()} | {:error, term()}