Files
sign/packages/prisma/index.ts

16 lines
407 B
TypeScript
Raw Normal View History

2023-01-07 17:52:46 +01:00
import { PrismaClient } 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
if (process.env.NODE_ENV !== "production") {
globalThis.client = prisma;
}
2023-01-09 17:10:36 +01:00
export default prisma;