Last active
July 15, 2023 06:43
-
-
Save dodycode/570efa5d6a9cde0923d22b4ef9de0e09 to your computer and use it in GitHub Desktop.
just prisma db thing for remix js..
This file contains hidden or 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 db = new PrismaClient(); | |
declare global { | |
var __db__: PrismaClient | undefined; | |
} | |
if (process.env.NODE_ENV === "production") { | |
db = new PrismaClient(); | |
} else { | |
if (!global.__db__) { | |
global.__db__ = new PrismaClient(); | |
} | |
db = global.__db__; | |
db.$connect(); | |
} | |
export { db }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment