ghostfolio/apps/api/src/services/prisma.service.ts

26 lines
468 B
TypeScript
Raw Normal View History

import {
Injectable,
Logger,
OnModuleDestroy,
OnModuleInit
} from '@nestjs/common';
2021-04-13 21:53:58 +02:00
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');
}
2021-04-13 21:53:58 +02:00
}
public async onModuleDestroy() {
2021-04-13 21:53:58 +02:00
await this.$disconnect();
}
}