cal.pub0.org/lib/prisma.ts

15 lines
318 B
TypeScript

import { PrismaClient } from '@prisma/client';
let prisma: PrismaClient;
const globalAny:any = global;
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
} else {
if (!globalAny.prisma) {
globalAny.prisma = new PrismaClient();
}
prisma = globalAny.prisma;
}
export default prisma;