Bird
0
0

Given the following Prisma call in a NestJS service:

medium📝 Predict Output Q4 of 15
NestJS - Database with Prisma
Given the following Prisma call in a NestJS service:
const user = await this.prisma.user.findUnique({ where: { id: 10 } });

What will be the value of user if no user with id 10 exists?
AAn empty object {}
Bnull
CAn error is thrown
Dundefined
Step-by-Step Solution
Solution:
  1. Step 1: Understand findUnique behavior

    findUnique returns the record if found, otherwise null.
  2. Step 2: Confirm no error thrown

    No error is thrown if record is missing; it returns null.
  3. Final Answer:

    null -> Option B
  4. Quick Check:

    findUnique missing record = null [OK]
Quick Trick: findUnique returns null if no record found [OK]
Common Mistakes:
  • Expecting an empty object instead of null
  • Assuming an error is thrown
  • Confusing undefined with null

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes