2025-12-08 11:23:58 +05:30
|
|
|
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
2025-11-10 15:05:01 +05:30
|
|
|
import { PrismaClient } from '@prisma/client';
|
2025-12-09 13:49:20 +05:30
|
|
|
import { prisma } from './prisma.client';
|
2025-11-10 15:05:01 +05:30
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
2025-12-09 13:49:20 +05:30
|
|
|
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();
|
|
|
|
|
}
|
2025-12-08 11:23:58 +05:30
|
|
|
}
|