How To Delete Many-To-Many Relation In Elixir Ecto — Tentamen Software Testing Blog

Elixir Ecto Many To Many Relation

TL;DR

Based on this excellent blog post, Many to many relationships with Ecto by Nuno Marinho, we successfully implemented many-to-many relations in our application. However, we needed a feature that required removing (deleting) many-to-many relations without deleting entities involved in this relation.

Deleting Many-To-Many Relation in Elixir Ecto

In Nuno post, you can find four steps on how to do proper many-to-many relation between Projects and Users using Elixir Ecto powers. However, one step is missing, how to remove the relation between Projects and Users.

The Wrong Way

Our first implementation was to do:

The Query For Deleting Many-To-Many Relation In Elixir Ecto

https://gist.github.com/karlosmid/c4b6abb224efa563592d56dc00d5efec

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store