Files
MinglarBackendNestJS/src/common/database/prisma.service.ts

21 lines
495 B
TypeScript
Raw Normal View History

import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
2025-11-10 15:05:01 +05:30
import { PrismaClient } from '@prisma/client';
import { prisma } from './prisma.client';
2025-11-10 15:05:01 +05:30
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
constructor() {
super();
// Use the singleton instance
Object.assign(this, prisma);
}
2025-11-10 15:05:01 +05:30
async onModuleInit() {
await this.$connect();
}
async onModuleDestroy() {
await this.$disconnect();
}
}