Force a Rollback Within a Transaction
Learn how to explicitly rollback within a transaction.
How Repo.transaction
works
Notice that we’ve been using insert!
with a bang rather than insert
. The two functions are identical except for one crucial difference—insert
will return {: error, value}
if the insert fails, but insert!
will raise an error. This is a convention used in many Elixir libraries, and it’s essential when executing transactions
with a function.
The ...
Get hands-on with 1400+ tech skills courses.