Tech
Generalizing Transactions in NestJS: A Domain Port over TypeORM and MongoDB
Transaction control usually starts out tied to whatever implements it. An executor — a concrete class that opens a transaction over the project's ORM — gets injected into the controller and wraps the body of the handler, so that everything a request writes either commits or is discarded as a block:
@ Post ()
create (@ Body () body : CreateUserRequest ) {
return this . transactionExecutor . execute ( async () =>
new RegisterUser ( this . ids ...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to