0
0
Firebasecloud~10 mins

Composite index requirements 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 composite index for fields 'age' and 'score'.

Firebase
firestore.indexes().create({fields: [{fieldPath: 'age'}, {fieldPath: '[1]'}]})
Drag options to blanks, or click blank then click option'
Alocation
Bname
Cdate
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a field not involved in the composite index like 'name' or 'location'.
2fill in blank
medium

Complete the code to specify the direction of the composite index on 'age' as ascending.

Firebase
firestore.indexes().create({fields: [{fieldPath: 'age', [1]: 'ASCENDING'}, {fieldPath: 'score', order: 'DESCENDING'}]})
Drag options to blanks, or click blank then click option'
Aorder
Bmode
Csort
Ddirection
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'direction' or 'sort' instead of 'order' causes errors.
3fill in blank
hard

Fix the error in the composite index definition by completing the missing field name.

Firebase
firestore.indexes().create({fields: [{fieldPath: 'age', order: 'ASCENDING'}, {fieldPath: '[1]', order: 'DESCENDING'}]})
Drag options to blanks, or click blank then click option'
Ascore
Bage
Cname
Dtimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Repeating 'age' or using unrelated fields like 'name' or 'timestamp'.
4fill in blank
hard

Fill both blanks to create a composite index with 'city' ascending and 'population' descending.

Firebase
firestore.indexes().create({fields: [{fieldPath: '[1]', order: 'ASCENDING'}, {fieldPath: '[2]', order: 'DESCENDING'}]})
Drag options to blanks, or click blank then click option'
Acity
Bpopulation
Cage
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the fields or using unrelated fields like 'age' or 'score'.
5fill in blank
hard

Fill all three blanks to define a composite index with 'country' ascending, 'state' ascending, and 'city' descending.

Firebase
firestore.indexes().create({fields: [{fieldPath: '[1]', order: 'ASCENDING'}, {fieldPath: '[2]', order: 'ASCENDING'}, {fieldPath: '[3]', order: 'DESCENDING'}]})
Drag options to blanks, or click blank then click option'
Acountry
Bstate
Ccity
Dpopulation
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'population' instead of 'city' for the descending field.