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