docs(docs): fix const reassignment in v7 upgrade Metrics example#7814
docs(docs): fix const reassignment in v7 upgrade Metrics example#7814nielskaspers wants to merge 1 commit intoprisma:mainfrom
Conversation
The totalQueries counter example in the "Metrics removed" section declared `total` with `const` but reassigned it inside `$allOperations`, which throws `TypeError: Assignment to constant variable` at runtime. Change `const` to `let` so the example actually runs. Closes prisma#7810
|
@nielskaspers is attempting to deploy a commit to the Prisma Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughDocumentation code example in the Upgrade to Prisma ORM v7 guide is corrected where a variable declaration changes from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/docs/content/docs/guides/upgrade-prisma-orm/v7.mdx (1)
313-317: Consider adding an actual query operation to demonstrate the counter.The example's
main()function doesn't execute any database queries, sototalQuerieswill always return 0. Adding a query operation (e.g.,await prisma.user.findMany()) before checking the total would better demonstrate the counter in action.📚 Suggested enhancement for clarity
async function main() { - prisma.$log("Hello world"); + // Execute a sample query to demonstrate the counter + await prisma.user.findMany(); + const totalQueries = await prisma.$totalQueries(); - console.log(totalQueries); + console.log(`Total queries executed: ${totalQueries}`); // Outputs: 1 }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/docs/content/docs/guides/upgrade-prisma-orm/v7.mdx` around lines 313 - 317, The example main() currently never runs a DB query so prisma.$totalQueries() returns 0; modify main() to perform at least one query (e.g., await prisma.user.findMany() or another model query) before calling prisma.$totalQueries() so the counter reflects executed queries; update references around the prisma.$log and prisma.$totalQueries() calls to place the query (await prisma.user.findMany()) prior to reading totalQueries.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/docs/content/docs/guides/upgrade-prisma-orm/v7.mdx`:
- Around line 313-317: The example main() currently never runs a DB query so
prisma.$totalQueries() returns 0; modify main() to perform at least one query
(e.g., await prisma.user.findMany() or another model query) before calling
prisma.$totalQueries() so the counter reflects executed queries; update
references around the prisma.$log and prisma.$totalQueries() calls to place the
query (await prisma.user.findMany()) prior to reading totalQueries.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c06a1f20-c206-4681-a3d5-d4a4dccbabe0
📒 Files selected for processing (1)
apps/docs/content/docs/guides/upgrade-prisma-orm/v7.mdx
Summary
The `totalQueries` counter example in the "Metrics removed" section of the Upgrade to Prisma ORM v7 guide declares `total` with `const` but reassigns it inside `$allOperations`. As written, the example throws `TypeError: Assignment to constant variable` at runtime (and fails to compile under TypeScript).
Issue
Fixes #7810
Changes
Testing
Summary by CodeRabbit