0
0
Firebasecloud~10 mins

Index management 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 single-field index on the 'age' field in Firestore.

Firebase
firestore.collection('users').orderBy('[1]').get()
Drag options to blanks, or click blank then click option'
Aname
Bage
Cemail
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name that does not exist in the collection.
2fill in blank
medium

Complete the code to create a composite index query filtering by 'status' and ordering by 'createdAt'.

Firebase
firestore.collection('orders').where('status', '==', '[1]').orderBy('createdAt').get()
Drag options to blanks, or click blank then click option'
Ashipped
Bcompleted
Ccancelled
Dpending
Attempts:
3 left
💡 Hint
Common Mistakes
Using a status value that does not exist in the data.
3fill in blank
hard

Fix the error in the Firestore query by completing the missing index field.

Firebase
firestore.collection('products').orderBy('category').orderBy('[1]').get()
Drag options to blanks, or click blank then click option'
Aprice
Bname
Cstock
Drating
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a field that is not indexed or not relevant for sorting.
4fill in blank
hard

Fill both blanks to create a Firestore query that filters by 'type' and orders by 'timestamp' descending.

Firebase
firestore.collection('events').where('type', '==', '[1]').orderBy('timestamp', '[2]').get()
Drag options to blanks, or click blank then click option'
Aconference
Basc
Cdesc
Dmeetup
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order when descending is required.
5fill in blank
hard

Fill all three blanks to create a Firestore query that filters by 'status', orders by 'priority' ascending, and limits results to 10.

Firebase
firestore.collection('tasks').where('status', '==', '[1]').orderBy('[2]', '[3]').limit(10).get()
Drag options to blanks, or click blank then click option'
Ain_progress
Bpriority
Casc
Ddesc
Attempts:
3 left
💡 Hint
Common Mistakes
Using descending order when ascending is needed.
Choosing wrong field names.