aboutsummaryrefslogtreecommitdiffstats
path: root/packages/db
diff options
context:
space:
mode:
Diffstat (limited to 'packages/db')
-rw-r--r--packages/db/index.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/packages/db/index.ts b/packages/db/index.ts
index 4a0f473f..e87b9515 100644
--- a/packages/db/index.ts
+++ b/packages/db/index.ts
@@ -1,14 +1,14 @@
import { PrismaClient } from "@prisma/client";
-const prisma = new PrismaClient({
- log:
- process.env.NODE_ENV === "development"
- ? ["query", "error", "warn"]
- : ["error"],
-});
-
-// For some weird reason accessing @prisma/client from any package is causing problems (specially in error handling).
-// Re export them here instead.
-export * from "@prisma/client";
+const globalForPrisma = globalThis as unknown as {
+ prisma: PrismaClient | undefined;
+};
-export default prisma;
+export const prisma =
+ globalForPrisma.prisma ??
+ new PrismaClient({
+ log:
+ process.env.NODE_ENV === "development"
+ ? ["query", "error", "warn"]
+ : ["error"],
+ });