Refactor Prisma client usage and enhance service integration for improved connection management

This commit is contained in:
paritosh18
2025-12-09 13:49:20 +05:30
parent a39cc1c3c8
commit b6cb5831c2
7 changed files with 49 additions and 38 deletions

View File

@@ -1,8 +1,15 @@
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import { prisma } from './prisma.client';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
constructor() {
super();
// Use the singleton instance
Object.assign(this, prisma);
}
async onModuleInit() {
await this.$connect();
}