Many-to-many associations in phoenix and ecto

Thats a good start at documenting the many_to_many macro.
If anyone can point the way, I’m looking for some description of how to use many_to_many in CRUD operations with change_sets.

The example you give is the way I am using many_to_many also. But if we need to manage the join table manually like that, I’m not seeing how this is any different that defining has_many on both sides.

Is there a developers guide somewhere that shows usage for the many_to_many macro?

from: https://hexdocs.pm/ecto/Ecto.Schema.html#many_to_many/3
It gives examples on how to get data back out.

# Get all comments for a given post
post = Repo.get(Post, 42)
tags = Repo.all assoc(post, :tags)

# The comments can come preloaded on the post struct
[post] = Repo.all(from(p in Post, where: p.id == 42, preload: :tags)) 
post.tags #=> [%Tag{...}, ...]

But what I’m completely stumped about is how to add, update, and delete data from a many_to_many.

4 Likes