[Proposal] Upstream the `Repo.transact` pattern

120 views
Skip to first unread message

Cristian Álvarez

unread,
Feb 22, 2024, 7:59:56 AMFeb 22
to elixir-ecto
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
Reply all
Reply to author
Forward
0 new messages