Skip to content

Instantly share code, notes, and snippets.

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