ash v1.6.5 Ash.Resource.Dsl.ManyToMany View Source
Link to this section Summary
Functions
Declares a many_to_many relationship. Many to many relationships require a join table.
Link to this section Functions
Declares a many_to_many relationship. Many to many relationships require a join table.
A join table is typically a table who's primary key consists of one foreign key to each resource.
Examples
# In a resource called `Word`
many_to_many :books, Book,
through: BookWord,
source_field: :text,
source_field_on_join_table: :word_text,
destination_field: :id,
destination_field_on_join_table: :book_id
Arguments
:name- The name of the relationship:destination- The destination resource
Options
:source_field_on_join_table- Required. The field on the join table that should line up withsource_fieldon this resource.:destination_field_on_join_table- Required. The field on the join table that should line up withdestination_fieldon the related resource. Default: [relationshihp_name]_id:through- Required. The resource to use as the join resource.:join_relationship- The has_many relationship to the join table. Defaults to <relationship_name>_join_assoc:join_attributes- Attributes to expose as editable when modifying the relationship.
Extensions may use this when deciding what fields to render from the join table.
See Ash.Changeset.append_to_relationship/3 and Ash.Changeset.replace_relationship/3 for
how to edit these fields. The default value is [].
:destination_field- The field on the related resource that should match thesource_fieldon this resource. The default value is:id.:source_field- The field on this resource that should match thedestination_fieldon the related resource. The default value is:id.:writable?- Whether or not the relationship may be edited. The default value istrue.