diff options
| author | Sebastien Castiel <sebastien@castiel.me> | 2023-12-05 17:39:05 -0500 |
|---|---|---|
| committer | Sebastien Castiel <sebastien@castiel.me> | 2023-12-05 17:39:05 -0500 |
| commit | ed55c696cd083bfaa5429082a9c5edd4ebde0cd8 (patch) | |
| tree | 9f387881f85716bcb4a05d6fce13bfe59fbc9c17 /src/lib/prisma.ts | |
| parent | 1fd6e48807d455f66d9cd79db64cbf9e9f947c6c (diff) | |
First version
Diffstat (limited to 'src/lib/prisma.ts')
| -rw-r--r-- | src/lib/prisma.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/prisma.ts b/src/lib/prisma.ts new file mode 100644 index 0000000..773547e --- /dev/null +++ b/src/lib/prisma.ts @@ -0,0 +1,17 @@ +import { PrismaClient } from '@prisma/client' + +let prisma: PrismaClient + +export function getPrisma() { + if (!prisma) { + if (process.env.NODE_ENV === 'production') { + prisma = new PrismaClient() + } else { + if (!(global as any).prisma) { + ;(global as any).prisma = new PrismaClient() + } + prisma = (global as any).prisma + } + } + return prisma +} |
