Skip to content

Commit

Permalink
[debug] correction conditionals in onPrisma
Browse files Browse the repository at this point in the history
  • Loading branch information
leomerida15 committed Feb 5, 2024
1 parent 7777989 commit 784f43b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/prisma/onPrisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ export const onPrisma = <PrismaClient>(
PrismaClientNative: new () => PrismaClient,
options?: onPrismaParamsOptios,
) => {
if ((global as Global<PrismaClient>).prisma)
return (global as Global<PrismaClient>).prisma;

if (options?.whereGlobal)
return prismaAddGlobalWhere(new PrismaClientNative(), options?.whereGlobal);

if (process.env.NODE_ENV !== "production" && !(global as any).prisma) {
if (!(global as Global<PrismaClient>).prisma && options?.whereGlobal) {
(global as any).prisma = prismaAddGlobalWhere(
new PrismaClientNative(),
options?.whereGlobal,
);
} else if (process.env.NODE_ENV !== "production" && !(global as any).prisma) {
(global as any).prisma = new PrismaClientNative();
}

Expand Down

0 comments on commit 784f43b

Please sign in to comment.