I have a many_to_many entry that I want to insert data into, how can I do that and create the join_through table entry too
I don’t think you can do it automatically. What’s wrong with encapsulating all the record-creating logic in a singular function though?
You can use cast_assoc/3
or put_assoc/4
to accomplish automatic mapping insertion. All data will be inserted using a transaction, equivalent to how Ecto.Multi works.
great but how do I use cast_assoc
if has_many
does not have the option on_replace: :update
?