mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
fix(prisma): ensure single Prisma Client instance in development
- Reference: https://www.prisma.io/docs/orm/more/help-and-troubleshooting/nextjs-help#recommended-solution
This commit is contained in:
parent
4b0d238d37
commit
862fbf1379
@ -1,11 +1,8 @@
|
|||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
const globalForPrisma = global as unknown as { prisma: PrismaClient };
|
||||||
|
|
||||||
const globalForPrisma = global as unknown as { prisma: typeof prisma };
|
export const prisma =
|
||||||
|
globalForPrisma.prisma || new PrismaClient();
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
|
||||||
globalForPrisma.prisma = prisma;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default prisma;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user