felia/packages/db/index.ts

20 lines
512 B
TypeScript
Raw Permalink Normal View History

2022-12-01 08:32:38 +00:00
import { PrismaClient } from "@prisma/client";
declare global {
// allow global `var` declarations
//
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}
export const prisma =
global.prisma ||
new PrismaClient({
log:
process.env.NODE_ENV === "development"
? ["query", "error", "warn"]
: ["error"],
});
export * from "@prisma/client";
if (process.env.NODE_ENV !== "production") {
global.prisma = prisma;
}