20 lines
486 B
TypeScript
20 lines
486 B
TypeScript
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
import { adapterPostgres } from 'prisma.config.postgres';
|
|
import { PrismaClient } from 'prisma/generated/postgres/client';
|
|
|
|
@Injectable()
|
|
export class PrismaPostgresService extends PrismaClient
|
|
implements OnModuleInit, OnModuleDestroy {
|
|
constructor() {
|
|
super({ adapter: adapterPostgres })
|
|
}
|
|
|
|
async onModuleInit() {
|
|
await this.$connect();
|
|
}
|
|
|
|
async onModuleDestroy() {
|
|
await this.$disconnect();
|
|
}
|
|
}
|