Code improvement and how to apply a transaction?

Not sure which parts of your code you want as part of the transaction but have a look at this thread:

There’s also a really good section on Transactions in the Programming Ecto (Pragprog) book :smiley:

The main thing to note is that you will want your non-DB part of the transaction to take place after the database part/s of the transaction.

3 Likes