try to fix creating multiple connections
This commit is contained in:
@@ -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;
|
||||||
|
Reference in New Issue
Block a user