Last active
January 18, 2024 22:42
-
-
Save Deri-Kurniawan/ac6b67440c60e34d2d48473d37d9a33f to your computer and use it in GitHub Desktop.
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"; | |
declare global { | |
var prisma: PrismaClient | undefined; | |
} | |
let 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