Complete the code to limit the number of documents retrieved to 5.
db.collection('users').limit([1]).get()
The limit method restricts the number of documents returned. Here, setting it to 5 means only 5 documents will be fetched.
Complete the code to start the query after the last document snapshot stored in 'lastDoc'.
db.collection('users').startAfter([1]).limit(5).get()
The startAfter method is used to continue fetching documents after a specific document snapshot. Here, 'lastDoc' is the last document from the previous query.
Fix the error in the code to correctly paginate documents by starting at the last document snapshot.
db.collection('users').[1](lastDoc).limit(5).get()
startAfter is the correct method to start fetching documents after the given document snapshot, enabling pagination without repeating the last document.
Fill both blanks to create a query that orders users by 'age' and limits results to 10.
db.collection('users').orderBy([1]).[2](10).get()
The orderBy method sorts documents by the 'age' field. The limit method restricts the number of documents to 10.
Fill all three blanks to paginate users ordered by 'score', starting after 'lastDoc', limiting to 7 results.
db.collection('users').orderBy([1]).[2]([3]).limit(7).get()
This query orders users by 'score', starts after the last document snapshot 'lastDoc' to avoid duplicates, and limits the results to 7 documents.