Thanks everyone, I just found the problem is I can't chain the save() right after create() which will call the entity's save() fn instead of the entityManager's one, and start a new transaction.

async createPrice(dto, entityManager){
  //wrong code
  return entityManager.create(PriceEntity, {...}).save();

  //works
  const price = entityManager.create(PriceEntity, {...});
  return entityManager.save(price);
  }
}
Answer from C TC on Stack Overflow
🌐
Papooch
papooch.github.io › plugins › available plugins › @nestjs-cls/transactional
@nestjs-cls/transactional | NestJS CLS
The Transactional plugin for nestjs-cls provides a generic interface that can be used to wrap any function call in a CLS-enabled transaction by storing the transaction reference in the CLS context.
🌐
npm
npmjs.com › package › @nestjs-cls › transactional
nestjs-cls/transactional
A "Transactional" plugin for nestjs-cls that provides a generic interface that can be used to wrap any function call in a CLS-enabled transaction by storing the transaction reference in the CLS context.
      » npm install @nestjs-cls/transactional
    
Published   May 25, 2026
Version   3.2.1
Discussions

How to use a transaction across multiple services in nestjs - Stack Overflow
How can I use transactions in nestjs within a service function that uses other services? async update(authContext: AuthContext, id: string, updatePortfolioDto: UpdatePortfolioDto, isSaved = false): More on stackoverflow.com
🌐 stackoverflow.com
Adding Transactional Annotation to NestJS
Is there an existing issue that is already proposing this? I have searched the existing issues Is your feature request related to a problem? Please describe it Currently, managing transactions involving multiple services in NestJS can be... More on github.com
🌐 github.com
3
May 24, 2023
nestjs / TypeOrm database transaction - Stack Overflow
Assuming we have 2 services, A and B. Service A has a function doing the following: Validate the data Call a service B function, that makes changes to the database Do some more stuff Do changes to ... More on stackoverflow.com
🌐 stackoverflow.com
Why I built typeorm-transactional-decorator
well, there’re reasons why it’s not included in official typeorm packages. i haven’t looked into your code, but i bet there will be shit tons of problems with edge cases. different propagation mechanisms also will lead to lots of problems. check this one out: https://github.com/Aliheym/typeorm-transactional it started with cls-hooked and then switched to AsynLocalStorage when it got introduced to Node. but it has never been adopted across community because of many underlying issues. in any case, good luck! More on reddit.com
🌐 r/nestjs
3
15
September 14, 2025
🌐
Medium
medium.com › @testjokerqwerty › integrating-typeorm-transactional-in-your-nest-js-project-a-step-by-step-guide-26d2093ef1b5
Integrating TypeORM-Transactional in Your Nest.js Project: A Step-by-Step Guide | by Eugene Moskalenko | Medium
November 27, 2024 - npm install @nestjs/typeorm typeorm pg · Install TypeORM-Transactional: Now, install the typeorm-transactional package: npm install typeorm-transactional · To configure TypeORM in a more flexible and environment-friendly way, we’ll use the @nestjs/config package along with dotenv to manage environment variables.
🌐
DEV Community
dev.to › alphamikle › the-easiest-way-to-use-transactions-in-nest-js-41h0
The easiest way to use transactions in Nest.js - DEV Community
February 13, 2021 - The ORM and Postgres settings are set by default, so each operation will be performed in its own transaction, but to take advantage of this advantage, you need to write one query in which all the logic associated with the database will take place at once.
🌐
npm
npmjs.com › package › @hodfords › nestjs-transaction
@hodfords/nestjs-transaction - npm
April 8, 2026 - In controllers, you can also use the @Transactional decorator to ensure that the entire request is wrapped in a transaction: import { Controller, Post } from '@nestjs/common'; import { Transactional } from '@hodfords/nestjs-transaction'; import { MyService } from './my.service'; @Controller('my') export class MyController { constructor(private myService: MyService) {} @Post('create') @Transactional() async create() { return this.myService.create(); } }
      » npm install @hodfords/nestjs-transaction
    
Published   Apr 08, 2026
Version   11.3.2
🌐
Medium
medium.com › @dev.muhammet.ozen › advanced-transaction-management-with-nestjs-typeorm-43a839363491
Advanced Transaction Management with NestJS & TypeORM | by Muhammet Özen | Medium
September 17, 2023 - Now we know how to implement transactions at a basic level, it’s time to implement transactions using repository design pattern and request-scoped providers. Note: I assume you already know how to use TypeORM and understand NestJS ecosystem at a basic level.
Find elsewhere
🌐
npm
npmjs.com › package › @nestjs-cls › transactional-adapter-typeorm
@nestjs-cls/transactional-adapter-typeorm - npm
May 25, 2026 - A typeorm adapter for @nestjs-cls/transactional. Latest version: 1.3.5, last published: 2 months ago. Start using @nestjs-cls/transactional-adapter-typeorm in your project by running `npm i @nestjs-cls/transactional-adapter-typeorm`. There are 0 other projects in the npm registry using ...
      » npm install @nestjs-cls/transactional-adapter-typeorm
    
Published   May 25, 2026
Version   1.3.5
🌐
GitHub
github.com › KIMBEOBWOO › nestjs-transaction › blob › master › README.md
nestjs-transaction/README.md at master · KIMBEOBWOO/nestjs-transaction
A Transactional Method Decorator for TypeORM that uses Async Local Storage to handle and propagate transactions between different repositories and service methods. - nestjs-transaction/README.md at master · KIMBEOBWOO/nestjs-transaction
Author   KIMBEOBWOO
🌐
Hodfords
opensource.hodfords.uk › nestjs-transaction
@hodfords/nestjs-transaction | Hodfords OpenSource
nestjs-transaction makes managing database transactions in NestJS easy and straightforward. It provides simple tools to start, commit, and roll back transactions, helping you ensure that multiple database operations are completed successfully ...
🌐
Stack Overflow
stackoverflow.com › questions › 77849015 › how-to-use-a-transaction-across-multiple-services-in-nestjs
How to use a transaction across multiple services in nestjs - Stack Overflow
I'd highly suggest the nestjs-cls library. Here's a blog post that describes how to use it: aaronboman.com/programming/2024/07/12/… ... Save this answer. ... Show activity on this post. I had a similar problem, and I solved it (perhaps not in the best way). But first, there's an important note about your code. ... "DO NOT USE GLOBAL ENTITY MANAGER. All operations MUST be executed using the provided transactional entity manager."
🌐
GitHub
github.com › alphamikle › nest_transact
GitHub - alphamikle/nest_transact: Simplest transactions support for Nestjs with Typeorm · GitHub
Simplest transactions support for Nestjs with Typeorm - alphamikle/nest_transact
Starred by 119 users
Forked by 20 users
Languages   TypeScript 94.9% | Shell 3.1% | JavaScript 1.9% | Dockerfile 0.1%
🌐
Aaron Boman
aaronboman.com › programming › 2020 › 05 › 15 › per-request-database-transactions-with-nestjs-and-typeorm
Per-Request Database Transactions with NestJS and TypeORM – Aaron Boman
July 12, 2024 - For the sake of brevity, I’ve not shown the createUser()code, but it performs a few different actions and all should be done within the same unit of work, so this solves my problem nicely and doesn’t add any extra special calls for retrieving a transaction-aware repository! NestJS provides a very powerful dependency injection mechanism that allows us to create a new transaction, scoped by request and then allow for other services to create repositories using the current transaction EntityManager if set so that large blocks of business logic can be executed atomically.
🌐
GitHub
github.com › nestjs › nest › issues › 11658
Adding Transactional Annotation to NestJS · Issue #11658 · nestjs/nest
May 24, 2023 - The proposed transaction annotation should provide a convenient way to define a transactional context in NestJS, ensuring that any database operations performed within the annotated code block are executed within a transaction.
Author   nestjs
🌐
Bytesmith
bytesmith.dev › blog › 20240320-nestjs-transactions
How I Harnessed Transactions in NestJS with TypeORM ...
March 19, 2024 - Launch your MVP in 30 days. ByteSmith is a precision-engineered boutique software studio that builds scalable, high-performance applications.
🌐
Medium
medium.com › @jsankit99 › transaction-management-in-nestjs-typeorm-3-3-the-transactional-decorator-7fd60466b8a4
Transaction Management in NestJS + TypeORM (3/3): The @Transactional Decorator | by Ankit Pradhan | Medium
January 28, 2026 - This service scans your application at startup and wraps all @Transactional methods automatically: import { Injectable, OnApplicationBootstrap } from '@nestjs/common'; import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core'; import { TRANSACTIONAL_KEY } from '../../decorators/transactional.decorator'; import { DbTransactionService } from '../db-transaction-service'; import { IsolationLevel } from 'typeorm/driver/types/IsolationLevel'; /** * Scans all providers in the application on bootstrap, * finds methods marked with @Transactional, * and wraps them in transaction logic automatically.
🌐
Aaron Boman
aaronboman.com › programming › 2024 › 07 › 12 › per-request-database-transactions-with-nestjs
Per-Request Database Transactions with NestJS – Aaron Boman
July 24, 2024 - This allows for attaching data to the current executing context (even across event loop interrupts) which will allow for us to attach anything we want to a specific request, i.e. the database transaction. Moving some request-specific context into AsyncLocalStorage will allow for us to remove the Scope.REQUEST from the Injectables and allow for us to take advantage of NestJS’s DI system for any extra context we might need during a transaction execution.
🌐
Reddit
reddit.com › r/nestjs › why i built typeorm-transactional-decorator
r/nestjs on Reddit: Why I built typeorm-transactional-decorator
September 14, 2025 -

I got tired of threading the EntityManager/QueryRunner through every layer of a modular NestJS backend—passing it as a parameter into every service and method. It was noisy, brittle, and honestly, a pain. I went hunting for a decorator-based solution for TypeORM transactions. I found a few, tried them, but they felt overconfigured and, crucially, the same transaction didn’t reliably propagate into deeply nested calls. Maybe I misused them—but the DX wasn’t there.

So I built typeorm-transactional-decorator: a small, focused layer that uses Node’s async hooks to carry a transactional context and patches TypeORM’s DataSource/EntityManager so repositories automatically bind to the current transaction if one exists. You get a dead-simple @Transactional decorator, @IgnoreTransaction to opt out where needed, reliable propagation into nested methods, automatic rollback on errors, and a TransactionResultManager to register side effects for onCommit/onRollback (think: delete an S3 file if the DB transaction fails). It’s based on typeorm-transactional, but simplified and tuned for a predictable, minimal workflow.

It slots neatly into NestJS via TypeOrmModule’s dataSourceFactory, or you can call addTransactionalDataSource(dataSource) in any Node app. The package grows as my needs evolve, but the north star is the same: minimal API, maximum ergonomics for real-world, layered architectures.

How are you handling TypeORM transactions?

NPM: https://www.npmjs.com/package/typeorm-transactional-decorator

🌐
Reddit
reddit.com › r/nestjs_framework › how do you handle database transactions in your nestjs project with typeorm?
r/Nestjs_framework on Reddit: How do you handle database transactions in your NestJs project with TypeORM?
March 6, 2023 -

Hello everyone,

I have been looking online for a nice way to handle database transactions in NestJs.

I looked at the examples in the docs and I read some articles online, but they all revolve around passing the EntityManager around.

I am guessing that I can't be the only one looking for a better alternative as passing that object around different methods across your codebase doesn't bother me only.

So, I am curious, did anyone find a better alternative to this? To somehow hide and abstract away the EntityManager?

Looking forward to hearing your thoughts!

Many thanks!