A. The operator 'equals' is invalid in where clause
B. The collection name 'orders' is incorrect
C. The field 'status' cannot be queried
D. The get() method is missing parentheses
Solution
Step 1: Check the operator used in where clause
Firebase supports operators like '==', '<', '>=', but not 'equals'.
Step 2: Verify other parts of the query
Collection name and field are valid, and get() is correctly called with parentheses.
Final Answer:
The operator 'equals' is invalid in where clause -> Option A
Quick Check:
Use '==' not 'equals' in where clause [OK]
Hint: Use '==' operator, not words like 'equals' [OK]
Common Mistakes:
Using 'equals' instead of '=='
Missing parentheses on get()
Assuming any string operator works
5. You want to get all users from the 'users' collection whose age is between 18 and 30 inclusive. Which Firebase query correctly achieves this?
hard
A. db.collection('users').where('age', '>', 18).where('age', '<', 30)
B. db.collection('users').where('age', '>=', 18).where('age', '<=', 30)
C. db.collection('users').where('age', '==', 18).where('age', '==', 30)
D. db.collection('users').where('age', '>=', 18 || '<=', 30)
Solution
Step 1: Understand how to filter a range in Firebase
Firebase allows chaining multiple where clauses to filter a range, e.g., age >= 18 and age <= 30.
Step 2: Analyze each option
db.collection('users').where('age', '>=', 18).where('age', '<=', 30) correctly uses two where clauses with '>=' and '<=' operators. db.collection('users').where('age', '>', 18).where('age', '<', 30) excludes 18 and 30 by using '>' and '<'. db.collection('users').where('age', '==', 18).where('age', '==', 30) tries to match age exactly 18 and 30 simultaneously, which is impossible. db.collection('users').where('age', '>=', 18 || '<=', 30) uses invalid syntax combining operators in one where.
Final Answer:
db.collection('users').where('age', '>=', 18).where('age', '<=', 30) -> Option B
Quick Check:
Chain where with >= and <= for inclusive range [OK]
Hint: Chain where clauses for range with >= and <= [OK]
Common Mistakes:
Using '==' twice for range
Combining operators incorrectly in one where
Using > and < excludes boundary values
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.