Bird
0
0

Given this Remix loader code using Prisma:

medium📝 Predict Output Q4 of 15
Remix - Performance
Given this Remix loader code using Prisma:
const users = await prisma.user.findMany({ where: { active: true }, select: { id: true, name: true } });

What will be the shape of the returned data?
AAn array of all user objects including inactive users
BAn array of objects with only 'id' and 'name' fields for active users
CAn array of objects with all fields for active users
DAn error because 'select' cannot be used with 'where'
Step-by-Step Solution
Solution:
  1. Step 1: Understand 'where' and 'select' usage

    'where' filters active users; 'select' limits fields to 'id' and 'name'.
  2. Step 2: Determine returned data shape

    Only active users are returned, each with just 'id' and 'name' fields.
  3. Final Answer:

    An array of objects with only 'id' and 'name' fields for active users -> Option B
  4. Quick Check:

    Filter + select = limited fields for filtered users [OK]
Quick Trick: Use 'select' to limit fields after filtering with 'where' [OK]
Common Mistakes:
MISTAKES
  • Assuming all users are returned
  • Expecting all fields despite 'select'
  • Thinking 'select' and 'where' cannot be combined

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes