From e5d08abb823d997ad1252c3a595b1398ab001171 Mon Sep 17 00:00:00 2001 From: peshak2008 <57281176+peshak2008@users.noreply.github.com> Date: Mon, 13 May 2024 12:58:27 -0400 Subject: [PATCH] Update index.ts change to work with vercel deploment --- src/db/index.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/db/index.ts b/src/db/index.ts index 4c65196..779df28 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -1,18 +1,12 @@ -import { PrismaClient } from '@prisma/client' +import { PrismaClient } from "@prisma/client"; declare global { - var cachedPrisma: PrismaClient + var prisma: PrismaClient | undefined; } -let prisma: PrismaClient -if (process.env.NODE_ENV === 'production') { - prisma = new PrismaClient() -} else { - if (!global.cachedPrisma) { - global.cachedPrisma = new PrismaClient() - } +const prisma = global.prisma || new PrismaClient({ log: ["info"] }); +if (process.env.NODE_ENV !== "production") global.prisma = prisma; + +export const db = prisma; - prisma = global.cachedPrisma -} -export const db = prisma