prisma qoc

This commit is contained in:
Timur Ercan
2023-01-10 14:48:40 +01:00
parent 79670b4ab4
commit aaad9fc0cd

View File

@ -1,9 +1,16 @@
import { PrismaClient } from "@prisma/client";
declare global {
var prismaClientSingleton: PrismaClient | undefined;
var client: PrismaClient | undefined;
}
export const prisma = globalThis.prismaClientSingleton || new PrismaClient();
// Instanciate new client if non exists
const prisma = globalThis.client || new PrismaClient();
// Save for reuse in dev environment to avoid many client instances in dev where restart and reloads
if (process.env.NODE_ENV !== "production") {
globalThis.client = prisma;
}
export default prisma;