Search⌘ K
AI Features

Introduction to Transactions and the Multi Module

Explore how to handle multiple database operations as a single unit using transactions and the Ecto Multi module in Elixir. Understand database rollbacks and learn when to use functions or Ecto.Multi for reliable updates.

Grouping operations

Throughout this course, we’ve been working with one database operation at a time. However, there are times when we have multiple operations that need to be treated as a group—they all need to succeed or fail together.

Example

A classic example is transferring money between two bank accounts. If we want to transfer $10 from Bob’s account and put it in Alice’s account (it’s always Bob and ...