Created
April 8, 2024 01:50
-
-
Save SH20RAJ/06e1e96bebaad0443e6940d05e7415d7 to your computer and use it in GitHub Desktop.
Creating Single Prisma ORM Instance
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; | |
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