2021-07-06 16:10:22 +00:00
|
|
|
import { PrismaClient } from "@prisma/client";
|
2021-03-22 13:48:48 +00:00
|
|
|
|
2021-12-01 10:32:08 +00:00
|
|
|
import { IS_PRODUCTION } from "@lib/config/constants";
|
|
|
|
|
2021-10-15 18:31:57 +00:00
|
|
|
declare global {
|
|
|
|
// eslint-disable-next-line no-var
|
|
|
|
var prisma: PrismaClient | undefined;
|
2021-03-22 13:48:48 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 18:31:57 +00:00
|
|
|
export const prisma =
|
|
|
|
globalThis.prisma ||
|
|
|
|
new PrismaClient({
|
|
|
|
log: ["query", "error", "warn"],
|
2021-07-06 16:10:22 +00:00
|
|
|
});
|
|
|
|
|
2021-12-01 10:32:08 +00:00
|
|
|
if (!IS_PRODUCTION) {
|
2021-10-15 18:31:57 +00:00
|
|
|
globalThis.prisma = prisma;
|
|
|
|
}
|
2021-07-06 16:10:22 +00:00
|
|
|
|
|
|
|
export default prisma;
|