mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-14 19:46:12 +01:00
21 lines
476 B
TypeScript
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
|
|
}
|