0
0
Firebasecloud~10 mins

Querying with where clause in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to query documents where the field 'age' equals 25.

Firebase
const query = collectionRef.where('age', '==', [1]);
Drag options to blanks, or click blank then click option'
A35
B25
C20
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong number in the filter.
Confusing the operator '==' with other operators.
2fill in blank
medium

Complete the code to query documents where the field 'status' is 'active'.

Firebase
const activeUsers = collectionRef.where('status', '==', [1]);
Drag options to blanks, or click blank then click option'
A'inactive'
B'pending'
C'active'
D'deleted'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the string value.
Using the wrong status value.
3fill in blank
hard

Fix the error in the query to find documents where 'score' is greater than 80.

Firebase
const highScores = collectionRef.where('score', [1], 80);
Drag options to blanks, or click blank then click option'
A==
B<
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '>'.
Using '<' which finds lower scores.
4fill in blank
hard

Fill both blanks to query documents where 'age' is less than 30 and 'status' is 'active'.

Firebase
const query = collectionRef.where('age', [1], 30).where('status', [2], 'active');
Drag options to blanks, or click blank then click option'
A<
B==
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' for age.
Using '!=' instead of '==' for status.
5fill in blank
hard

Fill all three blanks to query documents where 'score' is greater than 50, 'age' is less than 40, and 'status' is 'active'.

Firebase
const complexQuery = collectionRef.where('score', [1], 50).where('age', [2], 40).where('status', [3], 'active');
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up comparison operators.
Using '!=' instead of '==' for status.