1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 01:08:28 -04:00
jarv.is/lib/helpers/prisma.ts

18 lines
574 B
TypeScript

import { PrismaClient } from "@prisma/client/edge";
// creating PrismaClient here prevents next.js from starting too many concurrent prisma instances and exhausting the
// number of connection pools available (especially when hot reloading from `next dev`).
// https://pris.ly/d/help/next-js-best-practices
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
};
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log: ["query"],
});
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;