db.ts 320 B

123456789101112131415
  1. import { PrismaClient } from '@prisma/client'
  2. declare const global: { prisma: PrismaClient }
  3. let prisma: PrismaClient
  4. if (process.env.NODE_ENV === 'production') {
  5. prisma = new PrismaClient()
  6. } else {
  7. if (!global.prisma) {
  8. global.prisma = new PrismaClient()
  9. }
  10. prisma = global.prisma
  11. }
  12. export default prisma