Skip to content

Commit 9629299

Browse files
authored
Merge pull request #12 from luka0009/patch-1
instantiating PrismaClient
2 parents 7096c98 + 1a3a21d commit 9629299

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lib/prisma.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
import { PrismaClient } from "@prisma/client";
1+
import { PrismaClient } from '@prisma/client'
22

3-
export const prisma = new PrismaClient();
3+
const globalForPrisma = globalThis as unknown as {
4+
prisma: PrismaClient | undefined
5+
}
6+
7+
export const prisma = globalForPrisma.prisma ?? new PrismaClient()
8+
9+
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

0 commit comments

Comments
 (0)