Bird
0
0

You want to update a user's email in NestJS using Prisma with type safety. Which code snippet correctly uses Prisma's type-safe API?

hard📝 Application Q8 of 15
NestJS - Database with Prisma
You want to update a user's email in NestJS using Prisma with type safety. Which code snippet correctly uses Prisma's type-safe API?
Aawait prisma.user.update({ where: { id: 1 }, data: { email: 'new@example.com' } });
Bawait prisma.user.update({ id: 1, email: 'new@example.com' });
Cawait prisma.user.updateEmail(1, 'new@example.com');
Dawait prisma.updateUserEmail({ id: 1, email: 'new@example.com' });
Step-by-Step Solution
Solution:
  1. Step 1: Recall Prisma update method signature

    The update method requires an object with where and data keys.
  2. Step 2: Check each option

    await prisma.user.update({ where: { id: 1 }, data: { email: 'new@example.com' } }); matches the correct syntax; others use invalid method names or missing keys.
  3. Final Answer:

    await prisma.user.update({ where: { id: 1 }, data: { email: 'new@example.com' } }); -> Option A
  4. Quick Check:

    Correct update syntax = await prisma.user.update({ where: { id: 1 }, data: { email: 'new@example.com' } }); [OK]
Quick Trick: Use update({ where, data }) for safe updates [OK]
Common Mistakes:
  • Omitting where or data keys
  • Using non-existent methods
  • Passing parameters incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes