try to fix creating multiple connections

This commit is contained in:
KM Koushik
2025-07-22 17:42:16 +10:00
parent 0bc75e4474
commit f73a1c75ad

View File

@@ -2,6 +2,7 @@ import { PrismaClient } from "@prisma/client";
import { env } from "~/env"; import { env } from "~/env";
const createPrismaClient = () => { const createPrismaClient = () => {
console.log("Creating Prisma client");
const client = new PrismaClient({ const client = new PrismaClient({
log: log:
env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"], env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
@@ -17,4 +18,4 @@ const globalForPrisma = globalThis as unknown as {
export const db = globalForPrisma.prisma ?? createPrismaClient(); export const db = globalForPrisma.prisma ?? createPrismaClient();
if (env.NODE_ENV !== "production") globalForPrisma.prisma = db; globalForPrisma.prisma = db;