Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagarPakhrin/4bf4982b12dcaf809c10de2ed137d344 to your computer and use it in GitHub Desktop.
Save sagarPakhrin/4bf4982b12dcaf809c10de2ed137d344 to your computer and use it in GitHub Desktop.
prisma.service.ts
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