🔊 Added query logging for Prisma
This commit is contained in:
parent
d624c62669
commit
cf3f3449e8
1 changed files with 19 additions and 2 deletions
|
@ -1,3 +1,20 @@
|
|||
import { PrismaClient } from '@prisma/client'
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import logger from "../../middlewares/logger";
|
||||
|
||||
export default new PrismaClient()
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
prisma.$use(async (params, next) => {
|
||||
const before = Date.now();
|
||||
|
||||
const result = await next(params);
|
||||
|
||||
const after = Date.now();
|
||||
|
||||
logger.debug(
|
||||
`Query ${params.model}.${params.action} took ${after - before}ms`
|
||||
);
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
export default prisma;
|
||||
|
|
Loading…
Add table
Reference in a new issue