Files
spliit/src/lib/prisma.ts
Sebastien Castiel c1c75fa260 Q: Why do mountain climbers rope themselves together?
A:	To prevent the sensible ones from going home.
2024-10-25 15:02:31 -04:00

22 lines
509 B
TypeScript

import { PrismaClient } from '@prisma/client'
declare const global: Global & { prisma?: PrismaClient }
export let p: PrismaClient = undefined as unknown as PrismaClient
if (typeof window === 'undefined') {
// await delay(1000)
if (process.env['NODE_ENV'] === 'production') {
p = new PrismaClient()
} else {
if (!global.prisma) {
global.prisma = new PrismaClient({
// log: [{ emit: 'stdout', level: 'query' }],
})
}
p = global.prisma
}
}
export const prisma = p