ash v1.24.1 Ash.Resource.Dsl.Identities.Identity View Source

Link to this section Summary


Represents a unique constraint on the resource.

Link to this section Functions

Link to this macro

identity(name, keys, opts \\ [])

View Source (macro)

Represents a unique constraint on the resource.

Used for indicating that some set of attributes, calculations or aggregates uniquely identify a resource.

This will allow these fields to be passed to Ash.Api.get/3, e.g get(Resource, [some_field: 10]), if all of the keys are filterable. Otherwise they are purely descriptive at the moment. The primary key of the resource does not need to be listed as an identity.


identity :name, [:name]
identity :full_name, [:first_name, :last_name]


  • :name - The name of the identity. Used by extensions to target specific identities for fetching single instances of a resource

  • :keys - The names of attributes, aggregates or calculations that uniquely identify this resource.


  • :description - An optional description for the identity