2021-04-11 17:12:18 +00:00
|
|
|
import { PrismaClient } from '@prisma/client';
|
2021-03-22 13:48:48 +00:00
|
|
|
|
2021-04-11 17:12:18 +00:00
|
|
|
let prisma: PrismaClient;
|
2021-03-22 13:48:48 +00:00
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
2021-04-11 17:12:18 +00:00
|
|
|
prisma = new PrismaClient();
|
2021-03-22 13:48:48 +00:00
|
|
|
} else {
|
|
|
|
if (!global.prisma) {
|
2021-04-11 17:12:18 +00:00
|
|
|
global.prisma = new PrismaClient();
|
2021-03-22 13:48:48 +00:00
|
|
|
}
|
2021-04-11 17:12:18 +00:00
|
|
|
prisma = global.prisma;
|
2021-03-22 13:48:48 +00:00
|
|
|
}
|
|
|
|
|
2021-04-11 17:12:18 +00:00
|
|
|
export default prisma;
|