Adding db transaction in repository layer - #9
Conversation
c791faf to
f352316
Compare
|
Hi @chud-lori thanks for your contribution! However, I have some concerns about this approach. Right now, the transaction is handled entirely within the repository layer. This works fine if a use case only interacts with a single repository. But what if a use case needs to perform operations across multiple repositories and ensure they are all committed or rolled back together? For example, imagine a scenario where a single business process involves inserting data into both the A better approach might be to manage transactions at the use case (service) layer, where the transaction context can be shared across multiple repositories. That way, if something goes wrong in one repository, we can roll back the entire operation instead of leaving the system in a partial state. Would love to hear your thoughts on this! 🚀 |
|
I was thinking to keep it simple, but as boilerplate that's concern is valid, I have pushed the update to put the transaction on use case layer, but I haven't managed to write the tests due to the mockery on my local seems not working to generate a mock code, will get back once the test code works, cheers @syahidfrd |
…r usecase-layer transaction
Solve issue: #8
Tests result:
