The
Repo.transact pattern has gained some traction in the community. The Elixir Forum has
an amazing thread discussing what makes it valuable over Ecto.Multi and Repo.transaction.
Some big names in the Elixir community such as Wojtek Mach and Saša Jurić have shared their thoughts on the thread. The general consensus is that the Repo.transact pattern emphasises the usage of regular Elixir features and makes the code shorter.
The value proposition of Repo.transact is that control flow features such as passing data around, branching, early exit, can be implemented with standard Elixir features, such as variables, functions, and the with expression. The transactional logic is less special, and it doesn’t rely on some implicit behaviour of a function from some library.
Combined with the provable fact that the transact code is shorter (often significantly), even in such simple example as in that blog post, I have no doubt that the transact version is simpler and clearer.
I'm opening this conversation to see if:
1. The Ecto team agrees with the value of the Repo.transact pattern
2. If so, whether upstreaming that pattern into Ecto could be considered