Created
May 9, 2019 17:34
-
-
Save garretttaco/a3aac467b8e8836dc052f1c7f6bf971b to your computer and use it in GitHub Desktop.
Use MapSets to find differences in new ids vs current/existing ids. This really could be used for any many to many ids table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def diff_ids_update(new, existing) do | |
# Use MapSets to find differences in new ids vs current/existing ids. This really could be used for any many to many ids table. | |
new = new |> MapSet.new() | |
existing = existing |> MapSet.new() | |
remove = MapSet.difference(existing, new) |> MapSet.to_list() | |
add = MapSet.difference(new, existing) |> MapSet.to_list() | |
{remove, add} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment