use global client everywhere

This commit is contained in:
Thomas Ruoff
2022-10-14 22:43:26 +02:00
parent fbd1038e30
commit a500d6f76b
3 changed files with 18 additions and 15 deletions

16
db/client.ts Normal file
View File

@@ -0,0 +1,16 @@
import { PrismaClient } from '@prisma/client'
declare global {
// allow global `var` declarations
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined
}
export const prisma =
global.prisma ||
new PrismaClient({
log: ['query'],
})
if (process.env.NODE_ENV !== 'production') global.prisma = prisma