ash v0.1.1 Ash.Resource.Attributes View Source

A DSL component for declaring attributes

Attributes are fields on an instance of a resource. The two required pieces of knowledge are the field name, and the type.

Link to this section Summary

Functions

Declares an attribute on the resource

Link to this section Functions

Link to this macro

attribute(name, type, opts \\ [])

View Source (macro)

Declares an attribute on the resource

Type can be either a built in type (see Ash.Type) for more, or a module implementing the Ash.Type behaviour.


Opts

  • primary_key?(boolean): Whether this field is, or is part of, the primary key of a resource. - Default: false
  • default({:function, 0} | {module, atom} | {exactly(:constant), any}): A one argument function that returns a default value, an mfa that does the same, or a raw value via specifying {:constant, value}.

Examples

attribute :first_name, :string, primary_key?: true