In Ecto we can find two namings for an operation that either inserts or updates.
To my understanding:
-
Insert_or_update operation: inserts or updates whether an ID is present in the given schema
-
Upsert: tries to insert, if unique DB constraint error is returned from database, then updates
Is this distinction between these two namings made up by Elixir/Ecto? Or is this distinction also present in other frameworks?
What would you name your context functions?
insert_or_update_foo
or upsert_foo
?
I guess for the context’s API we must choose only one of those, because the strategy doesn’t have to be leaked and have different namings.