Files
AFFiNE-Mirror/packages/backend/server/src/prisma/service.ts
T

25 lines
527 B
TypeScript

import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
@Injectable()
export class PrismaService
extends PrismaClient
implements OnModuleInit, OnModuleDestroy
{
static INSTANCE: PrismaService | null = null;
constructor() {
super();
PrismaService.INSTANCE = this;
}
async onModuleInit() {
await this.$connect();
}
async onModuleDestroy(): Promise<void> {
await this.$disconnect();
}
}