NextJS_DOC/lib/Prisma.js

14 lines
277 B
JavaScript
Raw Permalink Normal View History

2023-03-24 10:11:04 +00:00
import { PrismaClient } from '@prisma/client';
let prisma;
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
} else {
if (!global.prisma) {
global.prisma = new PrismaClient();
}
prisma = global.prisma;
}
export default prisma;