Skip to content

Prisma Custom Client Location #55

Answered by jd4u
jd4u asked this question in Q&A
May 11, 2023 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

After exploring more, I see the following are required when prisma custom client location is used. Please correct me if wrong anywhere...

1] Use of CustomPrismaModule/CustomPrismaService (not to use PrismaModule/PrismaService anywhere)

2] Use Custom Location for referencing PrismaClient (not to use @prisma/client anywhere)

import { PrismaClient } from '@myLib/prisma'; // 👈 update to your output directory

3] Use CustomPrismaModule to register unique PrismaClient

CustomPrismaModule.forRoot({
      name: 'custPrismaService', // 👈 must be unique for each PrismaClient
      client: new PrismaClient(), // create new instance of PrismaClient
}),

4] Use for Injection CustomPrismaService (not to…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@marcjulian
Comment options

@jd4u
Comment options

@marcjulian
Comment options

@jd4u
Comment options

@marcjulian
Comment options

Answer selected by jd4u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants