我试图在我的 main.ts 上获取 PrismaService,但它一直崩溃。我是新手,谁能帮我解决这个问题?我的 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();
});
}
}
Run Code Online (Sandbox Code Playgroud)
我的主要.ts:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { PrismaService } from './prisma.service';
import { ValidationPipe } from '@nestjs/common';
import helmet from 'helmet';
async function bootstrap() …Run Code Online (Sandbox Code Playgroud)