Bird
0
0

This code causes a TypeScript error:

medium📝 Debug Q7 of 15
NestJS - Database with Prisma
This code causes a TypeScript error:
const users = await prisma.user.findMany({ where: { age: 'twenty' } });

What is the likely cause?
Aawait cannot be used with findMany
BfindMany does not accept where filters
Cprisma.user is not initialized
Dage should be a number, not a string
Step-by-Step Solution
Solution:
  1. Step 1: Check the type of age field

    Age is typically a number, so passing a string causes a type mismatch error.
  2. Step 2: Confirm TypeScript behavior

    TypeScript flags this mismatch to prevent runtime errors.
  3. Final Answer:

    age should be a number, not a string -> Option D
  4. Quick Check:

    Type mismatch causes error [OK]
Quick Trick: Use correct types for filters in queries [OK]
Common Mistakes:
  • Thinking findMany disallows where
  • Misunderstanding await usage
  • Assuming prisma.user is uninitialized

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes