Gathering detailed insights and metrics for prisma-debug-logs
Gathering detailed insights and metrics for prisma-debug-logs
Gathering detailed insights and metrics for prisma-debug-logs
Gathering detailed insights and metrics for prisma-debug-logs
npm install prisma-debug-logs
Typescript
Module System
Min. Node Version
Node Version
NPM Version
66.6
Supply Chain
90.6
Quality
76.4
Maintenance
100
Vulnerability
99.6
License
TypeScript (100%)
Total Downloads
2,952
Last Day
10
Last Week
95
Last Month
265
Last Year
2,952
1 Stars
6 Commits
2 Watching
1 Branches
1 Contributors
Latest Version
0.0.2
Package Id
prisma-debug-logs@0.0.2
Unpacked Size
25.77 kB
Size
6.32 kB
File Count
31
NPM Version
10.2.4
Node Version
20.11.1
Publised On
21 Feb 2024
Cumulative downloads
Total Downloads
Last day
150%
10
Compared to previous day
Last week
-5%
95
Compared to previous week
Last month
48.9%
265
Compared to previous month
Last year
0%
2,952
Compared to previous year
2
Prisma Debug Logs is an NPM package designed to aid in the debugging of applications using Prisma by providing enhanced logging capabilities. This package can be easily integrated into your Node.js projects as a development dependency to facilitate the capture and analysis of Prisma-generated SQL queries.
StatementExplainer
interface currently only has an implementation for Postgres, but you can make a PR for other RDBMSInstall prisma-debug-logs as a development dependency in your Node.js project using npm:
1npm install --save-dev prisma-debug-logs
After installation, you can configure Prisma Debug Logs in your project to start capturing Prisma logs. Here's a simple example to get you started:
1import { PrismaClient } from '@prisma/client' 2import { Pool } from 'pg' 3 4import { 5 DbLogger, 6 ExplainingConsolePrinter, 7 ExtendClient, 8 PgStatementExplainer, 9} from 'prisma-debug' 10 11function getDebugDbLogger(dbUrl: string) { 12 const pool = new Pool({ 13 connectionString: dbUrl, 14 }); 15 16 const pgStatementExplainer = new PgStatementExplainer(pool); 17 const explainingConsolePrinter = new ExplainingConsolePrinter(pgStatementExplainer); 18 19 return new DbLogger(explainingConsolePrinter); 20} 21 22function getDebugPrismaClient(dbUrl: string) { 23 return ExtendClient( 24 new PrismaClient({ 25 datasources: { db: { url: dbUrl } }, 26 log: [ 27 { 28 emit: 'event', 29 level: 'query', 30 }, 31 ], 32 }), 33 getDebugDbLogger(dbUrl), 34 ); 35} 36 37const client = getDebugPrismaClient('postgres://YourUserName:YourPassword@localhost:5432/YourDatabase') 38 39const result = await client.orders.findMany({ 40 where: { 41 order_id: 123, 42 }, 43 include: { 44 products: true, 45 }, 46})
Contributions are welcome! If you have ideas on how to improve Prisma Debug Logs or have encountered issues, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
No vulnerabilities found.
No security vulnerabilities found.