0
0
Firebasecloud~10 mins

Why compound queries narrow results in Firebase - Test Your Understanding

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 'status' equals 'active'.

Firebase
db.collection('users').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
Choosing a status that does not match the intended filter.
2fill in blank
medium

Complete the code to add a second condition to the query to filter users with age greater than 18.

Firebase
db.collection('users').where('status', '==', 'active').where('age', [1], 18)
Drag options to blanks, or click blank then click option'
A<=
B>
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' or '<' which select younger users.
3fill in blank
hard

Fix the error in the compound query that tries to filter by 'status' and 'age' but uses an invalid operator.

Firebase
db.collection('users').where('status', '==', 'active').where('age', [1], 18)
Drag options to blanks, or click blank then click option'
A>
Barray-contains
C!=
Din
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'array-contains' or 'in' with numeric fields.
4fill in blank
hard

Fill both blanks to create a compound query filtering users with 'status' 'active' and 'score' greater than 50.

Firebase
db.collection('users').where('status', [1], [2]).where('score', '>', 50)
Drag options to blanks, or click blank then click option'
A'=='
B'active'
C'inactive'
D'pending'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operator or status value.
5fill in blank
hard

Fill all three blanks to create a compound query filtering users with 'status' 'active', 'score' greater than 50, and 'age' less than 30.

Firebase
db.collection('users').where('status', [1], [2]).where('score', '>', 50).where('age', [3], 30)
Drag options to blanks, or click blank then click option'
A'=='
B'active'
C<
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators for age or status.