Comments (4)
Thanks, it works.
from nestjs-prisma.
Hi @Kasheftin yes that seems to be right. Additionally you have to pass the query
log option to the PrismaClient
. All PrismaClient
options are available in the PrismaModule.forRoot(..)
method.
import { Module } from '@nestjs/common';
import { PrismaModule } from 'nestjs-prisma';
@Module({
imports: [
PrismaModule.forRoot({
prismaServiceOptions: {
prismaOptions: {
log: [
{
emit: 'event',
level: 'query',
},
],
},
},
}),
],
})
export class AppModule {}
And little modification of your bootstrap function. You don't need to call await prismaService.onModuleInit()
, onModuleInit()
is a Nest lifecycle hook and would be managed by Nest itself.
// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { PrismaService } from 'nestjs-prisma';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const prismaService: PrismaService = app.get(PrismaService);
prismaService.$on('query', (e) => {
console.log(e);
});
await app.listen(process.env.PORT || 3000);
}
bootstrap();
Related to #23 (comment)
from nestjs-prisma.
I will open it again to add this to the documentation.
from nestjs-prisma.
Added to the docs https://nestjs-prisma.dev/docs/prisma-logging/
from nestjs-prisma.
Related Issues (20)
- using deprecated package
- Use of $extends HOT 2
- Property '$on' is missing in type HOT 8
- When will nestjs 10 be supported? HOT 2
- use extension instead of middleware HOT 1
- Error: "beforeExit" hook is not applicable to the library engine since Prisma 5.0.0, it is only relevant and implemented for the binary engine. Please add your event listener to the `process` object directly instead. HOT 8
- Options fail with latest nest cli HOT 2
- Prisma 5.0.0 Upgrade HOT 1
- PrismaService generator generates deprecated code HOT 3
- feat: add option to use generic http messages in Prisma exception filter HOT 1
- applicationRef undefined in nest e2e tests HOT 1
- error TS2307: Cannot find module '@nestjs-prisma' or its corresponding type declarations. HOT 1
- Extensions: `create` and `update` broken HOT 1
- Using extension packages (read replica) HOT 7
- Custom Prisma Client is not working HOT 13
- Bump prisma version HOT 2
- Link on `middleware` broken HOT 1
- CustomPrismaService unit testing HOT 2
- Feature Request: add support for using PrismaClientExceptionFilter as a controller/gateway/method level filter
- Possibility to use extensions and this.prisma. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-prisma.