ash v1.24.1 Ash.Resource.Dsl.ManyToMany View Source
Link to this section Summary
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.
# 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
:name- The name of the relationship
:destination- The destination resource
:source_field_on_join_table- Required. The field on the join table that should line up with
source_fieldon this resource.
:destination_field_on_join_table- Required. The field on the join table that should line up with
destination_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.
:destination_field- The field on the related resource that should match the
source_fieldon this resource. The default value is
:source_field- The field on this resource that should match the
destination_fieldon the related resource. The default value is
:writable?- Whether or not the relationship may be edited. The default value is
: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