ash v1.24.2 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
  | :multitenant
  | {:lateral_join, Ash.resource()}
  | {:join, Ash.resource()}
  | {:aggregate, Ash.aggregate_kind()}
  | {:query_aggregate, Ash.aggregate_kind()}
  | :aggregate_filter
  | :aggregate_sort
  | :boolean_filter
  | :async_engine
  | :create
  | :read
  | :update
  | :destroy
  | :limit
  | :offset
  | :transact
  | :filter
  | {:filter_operator, struct()}
  | {:filter_predicate, Ash.Type.t(), struct()}
  | :sort
  | {:sort, Ash.Type.t()}
  | :upsert
  | :composite_primary_key

Link to this section Functions

Link to this function

add_aggregate(query, aggregate, resource)

View Source

Specs

add_aggregate(Ash.data_layer_query(), Ash.aggregate(), Ash.resource()) ::
  {:ok, Ash.data_layer_query()} | {:error, term()}

Specs

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

create(resource, changeset)

View Source

Specs

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

destroy(resource, changeset)

View Source

Specs

destroy(Ash.resource(), Ash.changeset()) :: :ok | {:error, term()}
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

in_transaction?(resource)

View Source
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_aggregate_query(query, aggregates, resource)

View Source

Specs

run_aggregate_query(Ash.data_layer_query(), [Ash.aggregate()], Ash.resource()) ::
  {:ok, map()} | {:error, term()}
Link to this function

run_aggregate_query_with_lateral_join(query, aggregates, root_data, source_resource, destination_resource, source, destination)

View Source
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

run_query_with_lateral_join(query, root_data, source_resource, destination_resource, source, destination)

View Source
Link to this function

set_context(resource, query, map)

View Source

Specs

Link to this function

set_tenant(resource, query, term)

View Source

Specs

set_tenant(Ash.resource(), Ash.data_layer_query(), term()) ::
  {:ok, Ash.data_layer_query()} | {:error, Ash.error()}
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()}

Specs

source(Ash.resource()) :: String.t()
Link to this function

transact(resource, func)

View Source
Link to this function

update(resource, changeset)

View Source

Specs

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

upsert(resource, changeset)

View Source

Specs

upsert(Ash.resource(), Ash.changeset()) ::
  {:ok, Ash.record()} | {:error, term()}

Link to this section Callbacks

Link to this callback

add_aggregate(arg1, arg2, arg3)

View Source (optional)

Specs

add_aggregate(Ash.data_layer_query(), Ash.aggregate(), Ash.resource()) ::
  {:ok, Ash.data_layer_query()} | {:error, term()}

Specs

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

create(arg1, arg2)

View Source (optional)

Specs

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

destroy(arg1, arg2)

View Source (optional)

Specs

destroy(Ash.resource(), Ash.changeset()) :: :ok | {:error, term()}

Specs

equal?(Ash.data_layer()) :: boolean()
Link to this callback

filter(arg1, arg2, resource)

View Source (optional)

Specs

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

functions(arg1)

View Source (optional)

Specs

functions(Ash.resource()) :: [module()]
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 (optional)

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 (optional)

Specs

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

operators(arg1)

View Source (optional)

Specs

operators(Ash.resource()) :: [module()]
Link to this callback

resource_to_query(arg1)

View Source (optional)

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()
Link to this callback

run_aggregate_query(arg1, list, arg3)

View Source (optional)

Specs

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

run_aggregate_query_with_lateral_join(arg1, list, list, source_resource, destination_resource, source, destination)

View Source (optional)

Specs

run_aggregate_query_with_lateral_join(
  Ash.data_layer_query(),
  [Ash.aggregate()],
  [Ash.record()],
  source_resource :: Ash.resource(),
  destination_resource :: Ash.resource(),
  source :: atom(),
  destination :: atom()
) :: {:ok, [Ash.resource()]} | {:error, term()}
Link to this callback

run_query(arg1, arg2)

View Source (optional)

Specs

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

run_query_with_lateral_join(arg1, list, source_resource, destination_resource, source, destination)

View Source (optional)

Specs

run_query_with_lateral_join(
  Ash.data_layer_query(),
  [Ash.record()],
  source_resource :: Ash.resource(),
  destination_resource :: Ash.resource(),
  source :: atom(),
  destination :: atom()
) :: {:ok, [Ash.resource()]} | {:error, term()}
Link to this callback

set_context(arg1, arg2, map)

View Source (optional)

Specs

Link to this callback

set_tenant(arg1, arg2, term)

View Source (optional)

Specs

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

sort(arg1, arg2, resource)

View Source (optional)

Specs

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

Specs

source(Ash.resource()) :: String.t()
Link to this callback

transaction(arg1, function)

View Source (optional)

Specs

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

transform_query(arg1)

View Source (optional)

Specs

transform_query(Ash.query()) :: Ash.query()
Link to this callback

update(arg1, arg2)

View Source (optional)

Specs

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

upsert(arg1, arg2)

View Source (optional)

Specs

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