Skip to content

Commit b61bcfa

Browse files
authored
add onModuleDestroy (#230)
1 parent 2f93549 commit b61bcfa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

apps/api/src/prisma.service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { Injectable, OnModuleInit } from '@nestjs/common';
1+
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
22
import { PrismaClient } from '@prisma/client';
33

44
@Injectable()
5-
export class PrismaService extends PrismaClient implements OnModuleInit {
5+
export class PrismaService
6+
extends PrismaClient
7+
implements OnModuleInit, OnModuleDestroy
8+
{
69
constructor() {
710
super({
811
log:
@@ -15,4 +18,8 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
1518
async onModuleInit() {
1619
await this.$connect();
1720
}
21+
22+
async onModuleDestroy() {
23+
await this.$disconnect();
24+
}
1825
}

0 commit comments

Comments
 (0)