evolution-api/src/api/repository/repository.service.ts
2024-08-11 20:47:17 -03:00

29 lines
676 B
TypeScript

import { ConfigService } from '@config/env.config';
import { Logger } from '@config/logger.config';
import { PrismaClient } from '@prisma/client';
export class Query<T> {
where?: T;
sort?: 'asc' | 'desc';
page?: number;
offset?: number;
}
export class PrismaRepository extends PrismaClient {
constructor(private readonly configService: ConfigService) {
super();
}
private readonly logger = new Logger('PrismaRepository');
public async onModuleInit() {
await this.$connect();
this.logger.info('Repository:Prisma - ON');
}
public async onModuleDestroy() {
await this.$disconnect();
this.logger.warn('Repository:Prisma - OFF');
}
}