Bird
0
0

Why does Prisma's update() method require a unique identifier in the where clause?

hard📝 Conceptual Q10 of 15
NestJS - Database with Prisma
Why does Prisma's update() method require a unique identifier in the where clause?
ATo improve query performance by indexing
BBecause Prisma does not support updating multiple records
CTo ensure exactly one record is updated and avoid ambiguity
DBecause update() can only modify primary key fields
Step-by-Step Solution
Solution:
  1. Step 1: Understand update() requirements

    update() needs a unique identifier to target exactly one record.
  2. Step 2: Avoid ambiguity in updates

    Without unique where clause, Prisma cannot decide which record to update.
  3. Step 3: Evaluate other options

    Prisma supports updating multiple records via updateMany(), not update(); update() can modify any fields, not just primary keys.
  4. Final Answer:

    To ensure exactly one record is updated and avoid ambiguity -> Option C
  5. Quick Check:

    Unique where clause ensures single record update [OK]
Quick Trick: Unique where clause targets one record for update [OK]
Common Mistakes:
  • Thinking update() updates multiple records
  • Believing update() only changes primary keys
  • Assuming performance is the main reason

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes