import {
  Injectable,
  OnModuleInit,
  OnModuleDestroy,
  Logger,
} from '@nestjs/common';
import { PrismaClient } from '.prisma/crm-client';

@Injectable()
export class CrmPrismaService
  extends PrismaClient
  implements OnModuleInit, OnModuleDestroy
{
  private readonly logger = new Logger(CrmPrismaService.name);

  async onModuleInit(): Promise<void> {
    await this.$connect();
    this.logger.log('CRM Prisma Client verbunden.');
  }

  async onModuleDestroy(): Promise<void> {
    await this.$disconnect();
    this.logger.log('CRM Prisma Client getrennt.');
  }
}
