Bird
0
0

In a NestJS app using Prisma, you want to ensure your database queries are type-safe and reflect the latest schema changes. Which approach best achieves this?

hard📝 Application Q15 of 15
NestJS - Database with Prisma
In a NestJS app using Prisma, you want to ensure your database queries are type-safe and reflect the latest schema changes. Which approach best achieves this?
ARun <code>prisma generate</code> after updating the Prisma schema file
BManually write TypeScript types for your database models
CUse raw SQL queries inside Prisma without type checks
DDisable type checking in your IDE
Step-by-Step Solution
Solution:
  1. Step 1: Understand Prisma's code generation

    Running prisma generate updates the generated client with types matching the current schema.
  2. Step 2: Evaluate other options

    Manual types risk errors; raw SQL skips type safety; disabling checks removes benefits.
  3. Final Answer:

    Run prisma generate after updating the Prisma schema file -> Option A
  4. Quick Check:

    Generate client = updated type safety [OK]
Quick Trick: Always run prisma generate after schema changes [OK]
Common Mistakes:
  • Writing manual types instead of generating
  • Ignoring schema updates in code
  • Disabling helpful type checks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes