Papooch / nestjs-cls

A continuation-local storage (async context) module compatible with NestJS's dependency injection.

Home Page:https://papooch.github.io/nestjs-cls/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add typeorm Adapter for @nestjs-cls/transactional

giosueDelgado opened this issue · comments

The @nestjs-cls/transactional plugin currently supports a variety of ORM adapters like Prisma, Knex, and Pg-promise to enable CLS (Continuation Local Storage)-based transaction management. This feature allows transaction contexts to be passed seamlessly across different layers of an application without manually threading transaction objects through every call.

To extend the utility of this package to a broader audience, there is a need to implement an adapter for TypeORM. TypeORM is a widely-used ORM that supports both Active Record and Data Mapper patterns, making it a preferred choice for many TypeScript developers using NestJS.

Thanks, I'd like to mention (for the sake of context, as we talked on Discord previously) that there's a more complete implementation of the @Transactional decorator for TypeORM maintained by the community.

While supporting TypeORM was initially a non-goal, I changed my mind and I'm now not opposed to having an adapter for it, considering the linked implementation relies on monkey-patching TypeORM, which this plugin aims not to do.

I see you already created a PR, so let's address any technical details there.


P.S. I have a feeling that you let ChatGPT generate the issue text, am I right? 😅

Thanks, I'd like to mention (for the sake of context, as we talked on Discord previously) that there's a more complete implementation of the @Transactional decorator for TypeORM maintained by the community.

While supporting TypeORM was initially a non-goal, I changed my mind and I'm now not opposed to having an adapter for it, considering the linked implementation relies on monkey-patching TypeORM, which this plugin aims not to do.

I see you already created a PR, so let's address any technical details there.

P.S. I have a feeling that you let ChatGPT generate the issue text, am I right? 😅

Perfect! Yes I rewrite the issue text :)

Hey, Just come here to say it's not a good idea to support typeorm, lib almost is not maintainable and have a lot of breaking changes, it would be better to support MikroOrm

One of the popular issues: typeorm/typeorm#10638

@NarHakobyan I agree, adding MikroORM support was on my list, too (and I'm open to contributions).

But having an adapter for TypeORM doesn't hurt that much, since there's very little typeorm-specific code anyways.

Good evening.
@NarHakobyan I understand you, me and a new team are discussing with the creator of typeorm and we want to make great again TypeOrm (but this is another story...)
For the adapter is not a problem have it and use this for the many projects that at the moment are using TypeOrm. Have the adapter for typeorm is not exclusive to create also one for Mikrorm!

@nestjs-cls/transactional-adapter-typeorm was released.

@nestjs-cls/transactional-adapter-typeorm was released.

Cool! Thanks