Started introducing prisma to connect to MongoDB

This commit is contained in:
aronmal 2023-02-03 22:42:20 +01:00
parent 8397320a6b
commit 530a58f703
Signed by: aronmal
GPG key ID: 816B7707426FC612
11 changed files with 1734 additions and 42 deletions

15
leaky-ships/lib/prisma.ts Normal file
View file

@ -0,0 +1,15 @@
// lib/prisma.ts
import { PrismaClient } from '@prisma/client';
let prisma: PrismaClient;
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
} else {
if (!global.prismaClient) {
global.prismaClient = new PrismaClient();
}
prisma = global.prismaClient;
}
export default prisma;