Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { PrismaClient } from "@prisma/client";
- import "server-only";
- declare global {
- // eslint-disable-next-line no-var, no-unused-vars
- var cachedPrisma: PrismaClient;
- }
- export let prisma: PrismaClient;
- if (process.env.NODE_ENV === "production") {
- prisma = new PrismaClient();
- } else {
- if (!global.cachedPrisma) {
- global.cachedPrisma = new PrismaClient();
- }
- prisma = global.cachedPrisma;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement