Perform Upserts with Schemas
Learn how to perform upserts with schemas.
Create a new record using insert
Like insert_all,
the insert
function supports the on_conflict
option for performing upserts. However, insert
works with schema structs and the return value is different so we’ll have some extra considerations. Let’s see what this difference looks like exactly.
If you’ve been running these commands on your local setup, you should first run mix ecto.reset
to reset the database. Let’s try creating a new genre using the Genre
struct.
Get hands-on with 1400+ tech skills courses.