import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common'; import { PrismaClient } from '@prisma/client'; import { adapterPostgres } from 'prisma.config.postgres'; @Injectable() export class PrismaPostgresService extends PrismaClient implements OnModuleInit, OnModuleDestroy { readonly client: PrismaClient; constructor() { super({ adapter: adapterPostgres }), this.client = new PrismaClient({ adapter: adapterPostgres }); } async onModuleInit() { await this.client.$connect(); } async onModuleDestroy() { await this.client.$disconnect(); } }