ash v1.24.1 Ash.Resource.Dsl.HasMany View Source

Link to this section Summary

Functions

Declares a has_many relationship. There can be any number of related entities.

Link to this section Functions

Link to this macro

has_many(name, destination, opts \\ [])

View Source (macro)

Declares a has_many relationship. There can be any number of related entities.

Examples

# In a resource called `Word`
has_many :definitions, DictionaryDefinition,
  source_field: :text,
  destination_field: :word_text

Arguments

  • :name - The name of the relationship

  • :destination - The destination resource

Options

  • :destination_field - Required. The field on the related resource that should match the source_field on this resource.

  • :source_field - The field on this resource that should match the destination_field on the related resource. The default value is :id.

  • :writable? - Whether or not the relationship may be edited. The default value is true.

  • :description - An optional description for the relationship

  • :private? - Whether or not the relationship will appear in any interfaces created off of this resource, e.g AshJsonApi and AshGraphql The default value is false.