aboutsummaryrefslogtreecommitdiff
path: root/benchmark/frontend/src/server/db.ts
blob: 87ece8b70189ad624b1dd973946c654f5835cca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { PrismaClient } from "@prisma/client";
import { env } from "~/env.mjs";

const globalForPrisma = globalThis as unknown as {
  prisma: PrismaClient | undefined;
};

export const prisma =
  globalForPrisma.prisma ??
  new PrismaClient({
    log:
      env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
  });

if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;