ash v0.13.0 Ash.Resource View Source

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

Resource DSL documentation: Ash.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 attribute name from the resource

Returns all attributes of a resource

A list of authorizers to be used when accessing

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

Whether ornot the data layer supports a specific feature

Custom filters suppoted by the data layer of the resource

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

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 a relationship by name or path

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 datalayer

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

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

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 ornot the data layer supports a specific feature

Link to this function

data_layer_filters(resource)

View Source

Specs

data_layer_filters(Ash.resource()) :: map()

Custom filters suppoted by the data layer of 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

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

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() | [atom()]) :: Ash.relationship() | nil

Get a relationship by name or path

Specs

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

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 datalayer

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