Bird
0
0

Given this Prisma update call in a NestJS service:

medium📝 Predict Output Q13 of 15
NestJS - Database with Prisma
Given this Prisma update call in a NestJS service:
this.prisma.user.update({ where: { id: 5 }, data: { email: 'new@example.com' } })

What will this operation do?
ADelete the user with id 5
BUpdate the email of the user with id 5 to 'new@example.com'
CCreate a new user with id 5 and email 'new@example.com'
DReturn all users with email 'new@example.com'
Step-by-Step Solution
Solution:
  1. Step 1: Understand the update method parameters

    The update method requires a where clause to find the record and data to specify changes.
  2. Step 2: Analyze the given call

    It targets user with id: 5 and changes the email field to 'new@example.com'.
  3. Final Answer:

    Update the email of the user with id 5 to 'new@example.com' -> Option B
  4. Quick Check:

    Update with where and data changes record [OK]
Quick Trick: Update needs where to find record, data to change [OK]
Common Mistakes:
  • Thinking update creates new records
  • Confusing update with delete
  • Missing where clause causes errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes