Files
documenso/packages/prisma/index.ts
Timur Ercan 9f26da9316 build fix
2023-01-23 21:35:33 +01:00

16 lines
423 B
TypeScript

import { PrismaClient, Document, User } from "@prisma/client";
declare global {
var client: PrismaClient | undefined;
}
// 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;