NestJS - Database with PrismaWhy does Prisma's update() method require a unique identifier in the where clause?ATo improve query performance by indexingBBecause Prisma does not support updating multiple recordsCTo ensure exactly one record is updated and avoid ambiguityDBecause update() can only modify primary key fieldsCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand update() requirementsupdate() needs a unique identifier to target exactly one record.Step 2: Avoid ambiguity in updatesWithout unique where clause, Prisma cannot decide which record to update.Step 3: Evaluate other optionsPrisma supports updating multiple records via updateMany(), not update(); update() can modify any fields, not just primary keys.Final Answer:To ensure exactly one record is updated and avoid ambiguity -> Option CQuick 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 recordsBelieving update() only changes primary keysAssuming performance is the main reason
Master "Database with Prisma" in NestJS9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More NestJS Quizzes Authentication - Why authentication secures NestJS APIs - Quiz 11easy Authentication - Role-based authorization - Quiz 11easy Authentication - Token generation and validation - Quiz 11easy Database with TypeORM - Transactions - Quiz 8hard Guards - Combining multiple guards - Quiz 2easy Interceptors - Cache interceptor - Quiz 8hard Middleware - Applying middleware to routes - Quiz 12easy Middleware - Applying middleware to routes - Quiz 10hard Middleware - Middleware ordering - Quiz 2easy Pipes - File validation pipe - Quiz 1easy