Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use with extended client? #125

Closed
darr1s opened this issue Feb 20, 2024 · 2 comments
Closed

How to use with extended client? #125

darr1s opened this issue Feb 20, 2024 · 2 comments
Labels
question Further information is requested solved The question was answered or the problem was solved

Comments

@darr1s
Copy link

darr1s commented Feb 20, 2024

Hi! Thanks for the lib.

The question is as title. I have extended client (available in ts, or as nest service)

@Papooch
Copy link
Owner

Papooch commented Feb 21, 2024

Hi, I am not exactly sure which client or library you're referring to, as this GitHub repository is a monorepo with multiple nestjs-cls related libs, but from the working, I'm going to assume you're talking about an extended Prisma client and the library @nestjs-cls/transactional-adapter-prisma.

Unfortunately, it is not (easily) possible to use an extended client (that is, an another type than the one imported from @prisma/client) with the prisma adapter. I'm planning to add that option to the library, but for the time being, to achieve what you want, you'll have to create a custom adapter.

Fortunately, it is not that hard as the entire source-code of the prisma adapter can be found here

And basically the only thing that needs changing is the import at the very top(and the related uses) from import { PrismaClient } from '@prisma/client' to import { MyPrismaClient } from '../my/prisma-client.

Also please keep in mind, that since the propagated transaction object is the one that gets passed to prisma.$transaction(( THIS_ONE ) => ...), if you use a custom service that extends the PrismaClient with new class methods, those won't be available on the transaction object.

@Papooch Papooch added the question Further information is requested label Feb 21, 2024
@Papooch
Copy link
Owner

Papooch commented Feb 25, 2024

It it now possible to use a custom Prisma Client type since @nestjs-cls/transactional-adapter-prisma v1.1.0. Please see updated docs.

@Papooch Papooch closed this as completed Feb 25, 2024
@Papooch Papooch added the solved The question was answered or the problem was solved label Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested solved The question was answered or the problem was solved
Projects
None yet
Development

No branches or pull requests

2 participants