Replies: 1 comment
-
This should probably be moved to the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem Statement
Currently, when working with transactions in Drizzle ORM, one we need to explicitly pass the transaction object to every function that needs to participate in the transaction. This leads to verbose code and makes it challenging to manage transactions across multiple function calls, especially in complex business logic.
Example of current approach:
Proposed Solution
Implement an implicit transaction context using AsyncLocalStorage or a similar mechanism. This would allow functions to access the current transaction without explicitly passing it as an argument.
Example of proposed approach:
Benefits
Implementation Considerations
withTransaction
to create transaction contexts anduseTransaction
to access the current transaction.Questions for Discussion
Related Discussion
An old issue #1473 already brought up this idea and I think it has a valid point. It mentions https://www.baeldung.com/spring-transactional-propagation-isolation which could be taken as a reference for a drizzle implementation.
What are your thoughts on this? How are people rolling transaction context at the moment?
Beta Was this translation helpful? Give feedback.
All reactions