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
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
6 Commits
2 Watchers
1 Branches
1 Contributors
Updated on Feb 27, 2024
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
Published on
Feb 21, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
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.