Created
October 16, 2023 22:41
-
-
Save felipemotarocha/fa72e3b4e161cf98113673843d63d3e1 to your computer and use it in GitHub Desktop.
FSW Store - Prisma Client
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 cachedPrisma: PrismaClient; | |
} | |
let prisma: PrismaClient; | |
if (process.env.NODE_ENV === "production") { | |
prisma = new PrismaClient(); | |
} else { | |
if (!global.cachedPrisma) { | |
global.cachedPrisma = new PrismaClient(); | |
} | |
prisma = global.cachedPrisma; | |
} | |
export const db = prisma; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment