Files
spliit/src/lib/prisma.ts
2024-01-30 12:57:21 -05:00

21 lines
476 B
TypeScript

import { PrismaClient } from '@prisma/client'
let prisma: PrismaClient
export async function getPrisma() {
// await delay(1000)
if (!prisma) {
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient()
} else {
if (!(global as any).prisma) {
;(global as any).prisma = new PrismaClient({
// log: [{ emit: 'stdout', level: 'query' }],
})
}
prisma = (global as any).prisma
}
}
return prisma
}