Hint: Remember: Firestore uses chained where() for multiple conditions [OK]
Common Mistakes:
Using filter() instead of where()
Using query() which is invalid
Using select() which only picks fields
3. Given this Firestore query: db.collection('products').where('price', '<=', 100).where('inStock', '==', true) What kind of results will this query return?
medium
A. Products priced at 100 or less and currently in stock
B. All products priced above 100 and in stock
C. Products priced at 100 or less regardless of stock
D. Only products that are out of stock
Solution
Step 1: Analyze the first condition
The query filters products with price less than or equal to 100.
Step 2: Analyze the second condition
It also filters products where inStock is true, meaning available products.
Final Answer:
Products priced at 100 or less and currently in stock -> Option A
Quick Check:
Compound query narrows to price ≤ 100 AND inStock = true [OK]
Hint: Both conditions must be true for results [OK]
Common Mistakes:
Ignoring the inStock condition
Thinking price > 100 is included
Confusing AND with OR logic
4. You wrote this query: db.collection('orders').where('status', '==', 'shipped').where('status', '==', 'delivered') Why does this query return no results?
medium
A. Because the collection 'orders' does not exist.
B. Because the syntax for multiple where clauses is incorrect.
C. Because a document cannot have 'status' equal to both 'shipped' and 'delivered' at the same time.
D. Because Firestore does not support queries on the 'status' field.
Solution
Step 1: Understand the conditions on the same field
The query asks for documents where 'status' equals 'shipped' AND 'delivered' simultaneously.
Step 2: Realize the logical impossibility
A single field cannot have two different values at once, so no documents match both.
Final Answer:
Because a document cannot have 'status' equal to both 'shipped' and 'delivered' at the same time. -> Option C
Quick Check:
Same field with conflicting conditions returns no results [OK]
Hint: Same field can't equal two different values simultaneously [OK]
Common Mistakes:
Thinking syntax is wrong
Assuming Firestore disallows querying 'status'
Assuming collection absence causes this
5. You want to find users who are both 'active' and have a 'score' greater than 50. Which compound query correctly narrows results to this criteria?
hard
A. db.collection('users').where('active', '==', true).where('score', '>', 50)
B. db.collection('users').where('active', '==', true).where('score', '<', 50)
C. db.collection('users').where('active', '==', false).where('score', '>', 50)
D. db.collection('users').where('active', '==', true).where('score', '==', 50)
Solution
Step 1: Identify the conditions needed
Users must be 'active' (true) and have 'score' greater than 50.
Step 2: Match conditions to query options
db.collection('users').where('active', '==', true).where('score', '>', 50) matches both conditions correctly: active equals true and score greater than 50.
Final Answer:
db.collection('users').where('active', '==', true).where('score', '>', 50) -> Option A
Quick Check:
Correct compound query matches all criteria [OK]
Hint: Match conditions exactly to narrow results [OK]
Common Mistakes:
Using wrong comparison operators
Mixing true/false for active
Using equality instead of greater than
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.