diff options
Diffstat (limited to 'benchmark/frontend/src/server/db.ts')
-rw-r--r-- | benchmark/frontend/src/server/db.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/benchmark/frontend/src/server/db.ts b/benchmark/frontend/src/server/db.ts new file mode 100644 index 000000000..87ece8b70 --- /dev/null +++ b/benchmark/frontend/src/server/db.ts @@ -0,0 +1,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; |