aboutsummaryrefslogtreecommitdiff
path: root/lib/prisma.ts
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-12-24 13:03:54 +0700
committerFactiven <[email protected]>2023-12-24 13:03:54 +0700
commit50a0f0240d7fef133eb5acc1bea2b1168b08e9db (patch)
tree307e09e505580415a58d64b5fc3580e9235869f1 /lib/prisma.ts
parentUpdate README.md (#104) (diff)
downloadmoopa-50a0f0240d7fef133eb5acc1bea2b1168b08e9db.tar.xz
moopa-50a0f0240d7fef133eb5acc1bea2b1168b08e9db.zip
migrate to typescript
Diffstat (limited to 'lib/prisma.ts')
-rw-r--r--lib/prisma.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/prisma.ts b/lib/prisma.ts
new file mode 100644
index 0000000..55acf8d
--- /dev/null
+++ b/lib/prisma.ts
@@ -0,0 +1,9 @@
+import { PrismaClient } from "@prisma/client";
+
+declare global {
+ var prisma: PrismaClient | undefined;
+}
+
+export const prisma = global.prisma || new PrismaClient();
+
+if (process.env.NODE_ENV !== "production") global.prisma = prisma;