Should the joint table have its own primary_key/id or should it be a composite key built using both the above fields.
I came across using many_to_many for the same. I want 2 fields collections & products. I couldnt figure out how to do this even with join_keys: [product_id: :id, collection_id: :id]
I tried has_many, through: which is straight forward but only helps with reading.
For writing/updating I have to go through joint table but I am confused on how will new relations be updated/added/removed.
How much of this can be automated & what needs to handled manually?
I couldnt make the self-referencing relation work, so made a seperate collections table. Facing a tricky issue now.
When using many_to_many association between products & collections tables. When trying to cast_assoc during creating a new product & associating it with an existing collection, Ecto is trying to insert the collection(even when id is present) & hence failing. Below is what the changeset looks like.