Files
sign/packages/prisma/index.ts

17 lines
440 B
TypeScript
Raw Normal View History

2023-04-04 22:02:32 +00:00
import { isENVProd } from "@documenso/lib";
import { Document, PrismaClient, User } from "@prisma/client";
2023-01-07 15:10:26 +01:00
2023-01-09 17:10:36 +01:00
declare global {
2023-01-10 14:48:40 +01:00
var client: PrismaClient | undefined;
2023-01-09 17:10:36 +01:00
}
2023-01-10 14:48:40 +01:00
// 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
2023-03-09 13:17:44 +01:00
if (!isENVProd) {
2023-01-10 14:48:40 +01:00
globalThis.client = prisma;
}
2023-01-09 17:10:36 +01:00
export default prisma;