Last active
August 30, 2023 07:20
-
-
Save tech-shamp/915537adf2c8b0744e17a2e24e24c5e9 to your computer and use it in GitHub Desktop.
Prisma Client Declaration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PrismaClient } from "@prisma/client" | |
let prisma: PrismaClient | |
declare global { | |
namespace NodeJS { | |
interface Global { | |
prisma: PrismaClient | |
} | |
} | |
} | |
if (process.env.NODE_ENV === "production") { | |
prisma = new PrismaClient() | |
} else { | |
if (!global.prisma) { | |
global.prisma = new PrismaClient() | |
} | |
prisma = global.prisma | |
} | |
export default prisma |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment