ash v1.24.1 Ash.Resource View Source

A resource is a static definition of an entity in your system.

Resource DSL documentation: Ash.Resource.Dsl

Link to this section Summary

Functions

Returns the action with the matching name and type on the resource

Returns all actions of a resource

Get an aggregate by name

Returns all aggregates of a resource

Get an attribute name from the resource

Returns all attributes of a resource

A list of authorizers to be used when accessing

Get a calculation by name

Returns all calculations of a resource

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

Custom operators supported by the data layer of the resource

A list of identities for the resource

Whether or not the data layer for the resource is currently in a transaction

Get the multitenancy strategy for a resource

A list of notifiers to be used when accessing

Returns the primary action of a given type

Returns the primary action of the given type

A list of field names corresponding to the primary key

Get an aggregate by name

Returns all public aggregates of a resource

Get a public attribute name from the resource

Returns all public attributes of a resource

Get a public calculation by name

Returns all public calculations of a resource

Get a public relationship by name or path

Returns all public relationships of a resource

Get a relationship by name or path

Returns all relationships of a resource

Whether or not a given module is a resource module

Rolls back the current transaction

Wraps the execution of the function in a transaction with the resource's data_layer

A list of all validations for the resource

Link to this section Functions

Link to this function

action(resource, name, type)

View Source

Specs

action(Ash.resource(), atom(), Ash.action_type()) :: Ash.action() | nil

Returns the action with the matching name and type on the resource

Specs

actions(Ash.resource()) :: [Ash.action()]

Returns all actions of a resource

Link to this function

aggregate(resource, name)

View Source

Specs

aggregate(Ash.resource(), atom() | String.t()) :: Ash.aggregate() | nil

Get an aggregate by name

Specs

aggregates(Ash.resource()) :: [Ash.aggregate()]

Returns all aggregates of a resource

Link to this function

attribute(resource, name)

View Source

Specs

attribute(Ash.resource(), String.t() | atom()) :: Ash.attribute() | nil

Get an attribute name from the resource

Specs

attributes(Ash.resource()) :: [Ash.attribute()]

Returns all attributes of a resource

Specs

authorizers(Ash.resource()) :: [module()]

A list of authorizers to be used when accessing

Specs

base_filter(Ash.resource()) :: term()
Link to this function

calculation(resource, name)

View Source

Specs

calculation(Ash.resource(), atom() | String.t()) :: Ash.calculation() | nil

Get a calculation by name

Specs

calculations(Ash.resource()) :: [Ash.calculation()]

Returns all calculations of a resource

Specs

data_layer(Ash.resource()) :: Ash.data_layer()

The data layer of the resource, or nil if it does not have one

Link to this function

data_layer_can?(resource, feature)

View Source

Specs

data_layer_can?(Ash.resource(), Ash.DataLayer.feature()) :: boolean()

Whether or not the data layer supports a specific feature

Link to this function

data_layer_functions(resource)

View Source

Specs

data_layer_functions(Ash.resource()) :: map()

Custom functions supported by the data layer of the resource

Link to this function

data_layer_operators(resource)

View Source

Specs

data_layer_operators(Ash.resource()) :: map()

Custom operators supported by the data layer of the resource

Specs

description(Ash.resource()) :: String.t() | nil

Specs

identities(Ash.resource()) :: [Ash.Resource.Identity.t()]

A list of identities for the resource

Link to this function

in_transaction?(resource)

View Source

Specs

in_transaction?(Ash.resource()) :: boolean()

Whether or not the data layer for the resource is currently in a transaction

Link to this function

multitenancy_attribute(resource)

View Source

Specs

multitenancy_attribute(Ash.resource()) :: atom() | nil
Link to this function

multitenancy_global?(resource)

View Source

Specs

multitenancy_global?(Ash.resource()) :: atom() | nil
Link to this function

multitenancy_parse_attribute(resource)

View Source

Specs

multitenancy_parse_attribute(Ash.resource()) :: {atom(), atom(), [any()]}
Link to this function

multitenancy_source(resource)

View Source

Specs

multitenancy_source(Ash.resource()) :: atom() | nil
Link to this function

multitenancy_strategy(resource)

View Source

Specs

multitenancy_strategy(Ash.resource()) :: :context | :attribute | nil

Get the multitenancy strategy for a resource

Link to this function

multitenancy_template(resource)

View Source

Specs

multitenancy_template(Ash.resource()) :: atom() | nil

Specs

notifiers(Ash.resource()) :: [module()]

A list of notifiers to be used when accessing

Link to this function

primary_action(resource, type)

View Source

Specs

primary_action(Ash.resource(), Ash.action_type()) :: Ash.action() | nil

Returns the primary action of a given type

Link to this function

primary_action!(resource, type)

View Source

Specs

primary_action!(Ash.resource(), Ash.action_type()) :: Ash.action() | no_return()

Returns the primary action of the given type

Specs

primary_key(Ash.resource()) :: [atom()]

A list of field names corresponding to the primary key

Link to this function

public_aggregate(resource, name)

View Source

Specs

public_aggregate(Ash.resource(), atom() | String.t()) :: Ash.aggregate() | nil

Get an aggregate by name

Link to this function

public_aggregates(resource)

View Source

Specs

public_aggregates(Ash.resource()) :: [Ash.aggregate()]

Returns all public aggregates of a resource

Link to this function

public_attribute(resource, name)

View Source

Specs

public_attribute(Ash.resource(), String.t() | atom()) :: Ash.attribute() | nil

Get a public attribute name from the resource

Link to this function

public_attributes(resource)

View Source

Specs

public_attributes(Ash.resource()) :: [Ash.attribute()]

Returns all public attributes of a resource

Link to this function

public_calculation(resource, name)

View Source

Specs

public_calculation(Ash.resource(), atom() | String.t()) ::
  Ash.calculation() | nil

Get a public calculation by name

Link to this function

public_calculations(resource)

View Source

Specs

public_calculations(Ash.resource()) :: [Ash.calculation()]

Returns all public calculations of a resource

Link to this function

public_relationship(resource, relationship_name)

View Source

Get a public relationship by name or path

Link to this function

public_relationships(resource)

View Source

Specs

public_relationships(Ash.resource()) :: [Ash.relationship()]

Returns all public relationships of a resource

Link to this function

related(resource, relationship)

View Source

Specs

related(Ash.resource(), atom() | String.t() | [atom() | String.t()]) ::
  Ash.resource() | nil
Link to this function

relationship(resource, relationship_name)

View Source

Specs

relationship(Ash.resource(), atom() | String.t() | [atom() | String.t()]) ::
  Ash.relationship() | nil

Get a relationship by name or path

Specs

relationships(Ash.resource()) :: [Ash.relationship()]

Returns all relationships of a resource

Specs

resource?(module()) :: boolean()

Whether or not a given module is a resource module

Link to this function

rollback(resource, term)

View Source

Specs

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

Rolls back the current transaction

Link to this function

transaction(resource, func)

View Source

Specs

transaction(Ash.resource(), (() -> term())) :: term()

Wraps the execution of the function in a transaction with the resource's data_layer

Specs

validations(Ash.resource()) :: [Ash.validation()]

A list of all validations for the resource

Link to this function

validations(resource, type)

View Source

Specs

validations(Ash.resource(), :create | :update | :destroy) :: [Ash.validation()]