Ash.DataLayer behaviour (ash v1.37.2) 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
Functions
The data layer of the resource, or nil if it does not have one
Whether or not the data layer supports a specific feature
Custom functions supported by the data layer of the resource
Rolls back the current transaction
Wraps the execution of the function in a transaction with the resource's data_layer
Link to this section Types
Specs
data_layer_query() :: struct()
Specs
feature() :: :transact | :multitenant | {:lateral_join, Ash.Resource.t()} | {:join, Ash.Resource.t()} | {:aggregate, Ash.Query.Aggregate.kind()} | {:query_aggregate, Ash.Query.Aggregate.kind()} | :aggregate_filter | :aggregate_sort | :boolean_filter | :async_engine | :create | :read | :update | :destroy | :limit | :offset | :transact | :filter | {:filter_expr, struct()} | :sort | {:sort, Ash.Type.t()} | :upsert | :composite_primary_key
Specs
t() :: module()
Link to this section Functions
Specs
add_aggregate(data_layer_query(), Ash.Query.Aggregate.t(), Ash.Resource.t()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
can?(feature(), Ash.Resource.t()) :: boolean()
Specs
create(Ash.Resource.t(), Ash.Changeset.t()) :: {:ok, Ash.Resource.record()} | {:error, term()}
Specs
data_layer(Ash.Resource.t()) :: t()
The data layer of the resource, or nil if it does not have one
Specs
data_layer_can?(Ash.Resource.t(), feature()) :: boolean()
Whether or not the data layer supports a specific feature
Specs
data_layer_functions(Ash.Resource.t()) :: map()
Custom functions supported by the data layer of the resource
Specs
destroy(Ash.Resource.t(), Ash.Changeset.t()) :: :ok | {:error, term()}
Specs
filter(data_layer_query(), Ash.Filter.t(), Ash.Resource.t()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
limit(data_layer_query(), limit :: non_neg_integer(), Ash.Resource.t()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
offset(data_layer_query(), offset :: non_neg_integer(), Ash.Resource.t()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
resource_to_query(Ash.Resource.t(), Ash.Api.t()) :: data_layer_query()
Specs
rollback(Ash.Resource.t(), term()) :: no_return()
Rolls back the current transaction
Specs
run_aggregate_query( data_layer_query(), [Ash.Query.Aggregate.t()], Ash.Resource.t() ) :: {:ok, map()} | {:error, term()}
run_aggregate_query_with_lateral_join(query, aggregates, root_data, source_resource, destination_resource, source, destination)
View SourceSpecs
run_query(data_layer_query(), central_resource :: Ash.Resource.t()) :: {:ok, [Ash.Resource.record()]} | {:error, term()}
run_query_with_lateral_join(query, root_data, source_resource, destination_resource, source, destination)
View SourceSpecs
set_context(Ash.Resource.t(), data_layer_query(), map()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
set_tenant(Ash.Resource.t(), data_layer_query(), term()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
sort(data_layer_query(), Ash.Sort.t(), Ash.Resource.t()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
source(Ash.Resource.t()) :: String.t()
Specs
transaction(Ash.Resource.t(), (() -> term())) :: term()
Wraps the execution of the function in a transaction with the resource's data_layer
Specs
update(Ash.Resource.t(), Ash.Changeset.t()) :: {:ok, Ash.Resource.record()} | {:error, term()}
Specs
upsert(Ash.Resource.t(), Ash.Changeset.t()) :: {:ok, Ash.Resource.record()} | {:error, term()}
Link to this section Callbacks
Specs
add_aggregate(data_layer_query(), Ash.Query.Aggregate.t(), Ash.Resource.t()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
can?(Ash.Resource.t(), feature()) :: boolean()
Specs
create(Ash.Resource.t(), Ash.Changeset.t()) :: {:ok, Ash.Resource.t()} | {:error, term()}
Specs
destroy(Ash.Resource.t(), Ash.Changeset.t()) :: :ok | {:error, term()}
Specs
Specs
filter(data_layer_query(), Ash.Filter.t(), resource :: Ash.Resource.t()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
functions(Ash.Resource.t()) :: [module()]
Specs
in_transaction?(Ash.Resource.t()) :: boolean()
Specs
limit( data_layer_query(), limit :: non_neg_integer(), resource :: Ash.Resource.t() ) :: {:ok, data_layer_query()} | {:error, term()}
Specs
offset( data_layer_query(), offset :: non_neg_integer(), resource :: Ash.Resource.t() ) :: {:ok, data_layer_query()} | {:error, term()}
Specs
operators(Ash.Resource.t()) :: [module()]
Specs
resource_to_query(Ash.Resource.t(), Ash.Api.t()) :: data_layer_query()
Specs
rollback(Ash.Resource.t(), term()) :: no_return()
Specs
run_aggregate_query( data_layer_query(), [Ash.Query.Aggregate.t()], Ash.Resource.t() ) :: {:ok, map()} | {:error, term()}
run_aggregate_query_with_lateral_join(data_layer_query, list, list, source_resource, destination_resource, source, destination)
View Source (optional)Specs
run_aggregate_query_with_lateral_join( data_layer_query(), [Ash.Query.Aggregate.t()], [Ash.Resource.record()], source_resource :: Ash.Resource.t(), destination_resource :: Ash.Resource.t(), source :: atom(), destination :: atom() ) :: {:ok, [Ash.Resource.t()]} | {:error, term()}
Specs
run_query(data_layer_query(), Ash.Resource.t()) :: {:ok, [Ash.Resource.t()]} | {:error, term()}
run_query_with_lateral_join(data_layer_query, list, source_resource, destination_resource, source, destination)
View Source (optional)Specs
run_query_with_lateral_join( data_layer_query(), [Ash.Resource.record()], source_resource :: Ash.Resource.t(), destination_resource :: Ash.Resource.t(), source :: atom(), destination :: atom() ) :: {:ok, [Ash.Resource.t()]} | {:error, term()}
Specs
set_context(Ash.Resource.t(), data_layer_query(), map()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
set_tenant(Ash.Resource.t(), data_layer_query(), term()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
sort(data_layer_query(), Ash.Sort.t(), resource :: Ash.Resource.t()) :: {:ok, data_layer_query()} | {:error, term()}
Specs
source(Ash.Resource.t()) :: String.t()
Specs
transaction(Ash.Resource.t(), (() -> term())) :: {:ok, term()} | {:error, term()}
Specs
transform_query(Ash.Query.t()) :: Ash.Query.t()
Specs
update(Ash.Resource.t(), Ash.Changeset.t()) :: {:ok, Ash.Resource.t()} | {:error, term()}
Specs
upsert(Ash.Resource.t(), Ash.Changeset.t()) :: {:ok, Ash.Resource.t()} | {:error, term()}