Udo Schneider
AEAsh Elixir
•Created by Udo Schneider on 9/10/2023 in #support
How to effiently add thousands+ of entries to `many_to_many` relations
I'm having a brain freeze at the moment. I have
Control
s and Requirement
s with a many_to_many
relation (ControlRequirement
). I can set those using manage_relationship
... however I now have the use case where I need to add new relations one by one ... thousands of them. My understanding is that manage_relationship with :append_and_remove
expects a list ... so I'd need to fetch the list, add an item, remove duplicates and then provide this to manage_relationship, correct? I assume :append
will be the better choice here. To save on DB requests I was thinking of creating the join ControlRequirement entries directly. Is this the "Ash-way" of doing this?7 replies