mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-08 13:05:08 +09:00
18 lines
692 B
TypeScript
18 lines
692 B
TypeScript
import { PrismaClient, Prisma } from "@prisma/client";
|
|
import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
|
|
|
|
declare global {
|
|
// allow global `var` declarations
|
|
// eslint-disable-next-line no-var
|
|
var prisma: PrismaClient | undefined;
|
|
}
|
|
|
|
// this fixes the issue with `warn(prisma-client) There are already 10 instances of Prisma Client actively running.`
|
|
// explanation here
|
|
// https://www.prisma.io/docs/guides/database/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices
|
|
export const prisma = global.prisma || new PrismaClient();
|
|
|
|
if (process.env.NODE_ENV !== "production") global.prisma = prisma;
|
|
|
|
export { Prisma, PrismaClientKnownRequestError };
|