ash v0.10.0 Ash.Dsl View Source
The built in resource DSL. The three core DSL components of a resource are:
- attributes -
attributes/1
- relationships -
relationships/1
- actions -
actions/1
Link to this section Summary
Functions
A section for declaring resource actions.
A section for declaring attributes on the resource.
A section for declaring relationships on the resource.
Resource-wide configuration
Link to this section Functions
A section for declaring resource actions.
All manipulation of data through the underlying data layer happens through actions.
There are four types of action: create
, read
, update
, and destroy
. You may
recognize these from the acronym CRUD
. You can have multiple actions of the same
type, as long as they have different names. This is the primary mechanism for customizing
your resources to conform to your business logic. It is normal and expected to have
multiple actions of each type in a large application.
If you have multiple actions of the same type, one of them must be designated as the
primary action for that type, via: primary?: true
. This tells the ash what to do
if an action of that type is requested, but no specific action name is given.
Constructors
- create -
Ash.Dsl.Create
- read -
Ash.Dsl.Read
- update -
Ash.Dsl.Update
- destroy -
Ash.Dsl.Destroy
A section for declaring attributes on the resource.
Attributes are fields on an instance of a resource. The two required pieces of knowledge are the field name, and the type.
Constructors
- attribute -
Ash.Dsl.Attribute
- create_timestamp -
Ash.Dsl.CreateTimestamp
- update_timestamp -
Ash.Dsl.UpdateTimestamp
A section for declaring relationships on the resource.
Relationships are a core component of resource oriented design. Many components of Ash
will use these relationships. A simple use case is side_loading (done via the Ash.Query.side_load/2
).
Constructors
- has_one -
Ash.Dsl.HasOne
- has_many -
Ash.Dsl.HasMany
- many_to_many -
Ash.Dsl.ManyToMany
- belongs_to -
Ash.Dsl.BelongsTo
Resource-wide configuration
Options
:description