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

Link to this section Summary

Functions

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.

Examples

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

Arguments

  • :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.

Options

  • :description - An optional description for the identity