26 lines
468 B
TypeScript
26 lines
468 B
TypeScript
import {
|
|
Injectable,
|
|
Logger,
|
|
OnModuleDestroy,
|
|
OnModuleInit
|
|
} from '@nestjs/common';
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
@Injectable()
|
|
export class PrismaService
|
|
extends PrismaClient
|
|
implements OnModuleInit, OnModuleDestroy
|
|
{
|
|
public async onModuleInit() {
|
|
try {
|
|
await this.$connect();
|
|
} catch (error) {
|
|
Logger.error(error, 'PrismaService');
|
|
}
|
|
}
|
|
|
|
public async onModuleDestroy() {
|
|
await this.$disconnect();
|
|
}
|
|
}
|