mirror of
				https://github.com/DerTyp7/explainegy-nextjs.git
				synced 2025-10-31 13:47:11 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			714 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			714 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| 
 | |
| import { Prisma, PrismaClient } from "@prisma/client";
 | |
| 
 | |
| 
 | |
| declare global {
 | |
|   namespace NodeJS {
 | |
|     interface Global {
 | |
|       prisma: PrismaClient;
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| let prisma: PrismaClient;
 | |
| 
 | |
| if (typeof window === "undefined") {
 | |
|   if (process.env.NODE_ENV === "production") {
 | |
|     prisma = new PrismaClient();
 | |
|   } else {
 | |
|     // @ts-ignore
 | |
|     if (!global.prisma) {
 | |
|       // @ts-ignore
 | |
|       global.prisma = new PrismaClient();
 | |
|     }
 | |
|     // @ts-ignore
 | |
|     prisma = global.prisma;
 | |
|   }
 | |
| }
 | |
| // @ts-ignore
 | |
| export default prisma;
 | |
| 
 | |
| export type CategoryWithIncludes = Prisma.CategoryGetPayload<{ include: { articles: true, svg: true } }>
 | |
| export type ArticleWithIncludes = Prisma.ArticleGetPayload<{ include: { category: true } }>
 | 
