dev-mastery / comments-api

MIT License
1.92k stars 649 forks source link

How should I include Transactions, without breaking this source code architecture? #38

Closed garganshul108 closed 4 years ago

garganshul108 commented 4 years ago

Hello, First of all thanks for a wonderful tutorial!!

I am working on an Express-based API that uses MySQL for data persistence. I have to implement a confirm order functionality

I know how to run Mysql specific transactions and all the things, but with a lot of coupling and poor source code architecture. (If I do it that way, then DB won't be like plugin anymore)

I am not able to understand how to do this while maintaining the architecture and at what layer to implement this transaction thing, use-case/data-access, or what? Thanks in advance

PS: also suggest to me, if it is an automation logic or business logic?

arcdev1 commented 4 years ago

If you need transactions you probably should reach for a UnitOfWork. Here's a decent description: https://dejanvasic.wordpress.com/2020/01/03/unit-of-work-with-node-mssql-and-typescript/

garganshul108 commented 4 years ago

Thanks, Bill!

garganshul108 commented 4 years ago

If you allow me, I have a request.

Please Please Please! Make a similar API using Java Spring Boot.