mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-14 19:46:12 +01:00
19 lines
409 B
TypeScript
19 lines
409 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()
|
|
}
|
|
prisma = (global as any).prisma
|
|
}
|
|
}
|
|
return prisma
|
|
}
|