ash v0.10.0 Ash.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_field
on this resource.:destination_field_on_join_table
- Required. The field on the join table that should line up withdestination_field
on the related resource. Default: [relationshihp_name]_id:through
- Required. The resource to use as the join resource.:destination_field
- false The field on the related resource that should match thesource_field
on this resource. The default value is:id
.:source_field
- false The field on this resource that should match thedestination_field
on the related resource. The default value is:id
.