diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-11-09 15:40:16 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-11-09 15:40:16 +0700 |
| commit | be0f537dc4fe384eef09436833c6407e6482c16d (patch) | |
| tree | 194b1ad3f34396cb8149075bbbd38b854aedf361 /prisma/client.ts | |
| parent | 5d5401ae36e7e0c8eb38ccd943c1aa44a9573d35 (diff) | |
Initial commit
Diffstat (limited to 'prisma/client.ts')
| -rw-r--r-- | prisma/client.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/prisma/client.ts b/prisma/client.ts new file mode 100644 index 0000000..16df655 --- /dev/null +++ b/prisma/client.ts @@ -0,0 +1,15 @@ +import { PrismaClient } from "@prisma/client"; + +const prismaClientSingleton = () => { + return new PrismaClient(); +}; + +type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>; + +const globalForPrisma = globalThis as unknown as { + prisma: PrismaClientSingleton | undefined; +}; + +export const prisma = globalForPrisma.prisma ?? prismaClientSingleton(); + +if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma; |
