0
0
Firebasecloud~10 mins

Limit and pagination 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 limit the number of documents retrieved to 5.

Firebase
db.collection('users').limit([1]).get()
Drag options to blanks, or click blank then click option'
A15
B20
C5
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number larger than needed.
Forgetting to use the limit method.
2fill in blank
medium

Complete the code to start the query after the last document snapshot stored in 'lastDoc'.

Firebase
db.collection('users').startAfter([1]).limit(5).get()
Drag options to blanks, or click blank then click option'
AfirstDoc
BlastDoc
CprevDoc
DnextDoc
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable that does not hold a document snapshot.
Confusing 'startAfter' with 'startAt'.
3fill in blank
hard

Fix the error in the code to correctly paginate documents by starting at the last document snapshot.

Firebase
db.collection('users').[1](lastDoc).limit(5).get()
Drag options to blanks, or click blank then click option'
AstartAfter
BstartAt
CendBefore
DendAt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'startAt' which causes duplicate documents in pagination.
Using 'endAt' or 'endBefore' which are for ending queries.
4fill in blank
hard

Fill both blanks to create a query that orders users by 'age' and limits results to 10.

Firebase
db.collection('users').orderBy([1]).[2](10).get()
Drag options to blanks, or click blank then click option'
A'age'
Blimit
CstartAfter
D'name'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'startAfter' instead of 'limit' for limiting results.
Ordering by a wrong field name.
5fill in blank
hard

Fill all three blanks to paginate users ordered by 'score', starting after 'lastDoc', limiting to 7 results.

Firebase
db.collection('users').orderBy([1]).[2]([3]).limit(7).get()
Drag options to blanks, or click blank then click option'
A'score'
BstartAfter
ClastDoc
Dlimit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'limit' instead of 'startAfter' for pagination.
Not ordering by the correct field.
Passing a wrong variable to 'startAfter'.