Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save skolhustick/0ead547908f622e4a3cb728ae8fd80ca to your computer and use it in GitHub Desktop.

Select an option

Save skolhustick/0ead547908f622e4a3cb728ae8fd80ca to your computer and use it in GitHub Desktop.
next-js-prisma-orm-mongodb-prisma:prisma.js
// prisma/prisma.js
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