Created
July 18, 2018 09:09
-
-
Save b0oh/2e5dc73d5c74841708dc0ca5fef66630 to your computer and use it in GitHub Desktop.
Upsert
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
| changeset = | |
| ProviderSelection.upsert_changeset(%{ | |
| entity_id: entity_id, | |
| entity_type: entity_type, | |
| provider: provider | |
| }) | |
| set_values = | |
| changeset.changes | |
| |> Keyword.new() | |
| on_conflict = | |
| ProviderSelection | |
| |> update(set: ^set_values) | |
| insert_options = [ | |
| conflict_target: [:entity_id, :entity_type], | |
| on_conflict: on_conflict | |
| ] | |
| Repo.insert!(changeset, insert_options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment