mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 02:26:21 +08:00
25 lines
527 B
TypeScript
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();
|
|
}
|
|
}
|