0
0
Firebasecloud~10 mins

In and not-in queries 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 'status' is in a list of values.

Firebase
db.collection('orders').where('status', '[1]', ['pending', 'shipped']).get()
Drag options to blanks, or click blank then click option'
Anot-in
Bin
C==
Darray-contains
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'array-contains' which checks if an array field contains a value, not if a field matches any value in a list.
Using '==' which only checks for equality with a single value.
2fill in blank
medium

Complete the code to query documents where the field 'category' is not in a list of values.

Firebase
db.collection('products').where('category', '[1]', ['electronics', 'furniture']).get()
Drag options to blanks, or click blank then click option'
A!=
Barray-contains-any
Cin
Dnot-in
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' which only compares to a single value, not a list.
Using 'in' which includes documents with matching values instead of excluding them.
3fill in blank
hard

Fix the error in the query to find documents where 'tags' array contains any of the given values.

Firebase
db.collection('posts').where('tags', '[1]', ['news', 'updates']).get()
Drag options to blanks, or click blank then click option'
Aarray-contains-any
Bin
Carray-contains
Dnot-in
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'in' which checks a field's value against a list, not array contents.
Using 'array-contains' which only checks for a single value.
4fill in blank
hard

Fill both blanks to query documents where 'status' is in a list and 'priority' is not in another list.

Firebase
db.collection('tasks').where('status', '[1]', ['open', 'in-progress']).where('priority', '[2]', ['low', 'medium']).get()
Drag options to blanks, or click blank then click option'
Ain
Barray-contains
Cnot-in
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which only compares single values.
Mixing up 'in' and 'not-in' operators.
5fill in blank
hard

Fill all three blanks to query documents where 'category' is in a list, 'tags' array contains any value from a list, and 'status' is not in another list.

Firebase
db.collection('items').where('category', '[1]', ['books', 'games']).where('tags', '[2]', ['bestseller', 'new']).where('status', '[3]', ['archived', 'deleted']).get()
Drag options to blanks, or click blank then click option'
Ain
Barray-contains-any
Cnot-in
Darray-contains
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'array-contains' instead of 'array-contains-any' for multiple values.
Using 'in' instead of 'not-in' to exclude values.