Created
March 11, 2022 18:19
-
-
Save sagarPakhrin/4bf4982b12dcaf809c10de2ed137d344 to your computer and use it in GitHub Desktop.
prisma.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common'; | |
import { PrismaClient } from '@prisma/client'; | |
@Injectable() | |
export class PrismaService extends PrismaClient | |
implements OnModuleInit { | |
async onModuleInit() { | |
await this.$connect(); | |
} | |
async enableShutdownHooks(app: INestApplication) { | |
this.$on('beforeExit', async () => { | |
await app.close(); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment