0
0
Firebasecloud~10 mins

Query limitations and workarounds 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 create a Firestore query that filters 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'active'
C'pending'
D'deleted'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong status value like 'inactive' or 'pending'.
2fill in blank
medium

Complete the code to order Firestore query results by the 'createdAt' timestamp in descending order.

Firebase
db.collection('posts').orderBy('createdAt', [1])
Drag options to blanks, or click blank then click option'
A'desc'
B'ascending'
C'asc'
D'descending'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'asc' which orders from oldest to newest.
3fill in blank
hard

Fix the error in the Firestore query that tries to filter by two different fields without an index.

Firebase
db.collection('orders').where('status', '==', 'shipped').where('[1]', '==', 'priority')
Drag options to blanks, or click blank then click option'
Apriority
Bcustomer
Cdate
Damount
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name that does not match the filter value.
4fill in blank
hard

Fill both blanks to create a Firestore query that limits results to 10 and starts after a given document snapshot.

Firebase
db.collection('messages').orderBy('timestamp').[1](10).[2](lastVisible)
Drag options to blanks, or click blank then click option'
Alimit
BstartAfter
CendBefore
Doffset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'endBefore' or 'offset' which do not fit this pagination pattern.
5fill in blank
hard

Fill all three blanks to create a Firestore query that filters by 'category', orders by 'price', and limits to 5 results.

Firebase
db.collection('products').where('category', '==', [1]).orderBy([2]).[3](5)
Drag options to blanks, or click blank then click option'
A'electronics'
B'price'
Climit
D'name'
Attempts:
3 left
💡 Hint
Common Mistakes
Ordering by 'name' instead of 'price' or missing the limit method.