This commit is contained in:
2026-03-12 20:27:11 -05:00
parent e007d54fb3
commit 13f53badc3
4 changed files with 19 additions and 9 deletions

View File

@@ -4,10 +4,13 @@ const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined
}
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
})
function getPrisma(): PrismaClient {
if (!globalForPrisma.prisma) {
globalForPrisma.prisma = new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
})
}
return globalForPrisma.prisma
}
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
export const prisma = getPrisma()