Run Transactions with Functions
Learn how to run transactions with functions.
We'll cover the following...
The first way to run Repo.transaction
is to pass in a function containing the operations we’d like to run within the transaction. This can be an anonymous function or a named function defined elsewhere. This seems like a good idea—we’re functional programmers, and this approach will let us keep using functions. Let’s try it out.
The working of Repo.transaction
To illustrate how this works, we will introduce a new ...