2026-01-03 14:07:04 +00:00
|
|
|
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
|
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
2026-01-04 23:26:03 +00:00
|
|
|
constructor() {
|
|
|
|
|
super({
|
|
|
|
|
datasources: {
|
|
|
|
|
db: {
|
|
|
|
|
url: process.env.DATABASE_URL,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-03 14:07:04 +00:00
|
|
|
async onModuleInit() {
|
|
|
|
|
await this.$connect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onModuleDestroy() {
|
|
|
|
|
await this.$disconnect();
|
|
|
|
|
}
|
|
|
|
|
}
|