Reputation: 4007
Hi Im using cloud firestore and flutter. I want to query firestore in a way that i will get one by one element from the query and not all at once. Im developing a card game when the user will draw cards from a deck and can decide when to stop, so i don't want to query more than I the user needs to. Im looking at startAtDocument() that might be a solution but not sure what will be the best practice.
Upvotes: 0
Views: 57
Reputation: 598827
If you want to limit a query to return at most one document, you can just .limit(1)
to the end of your query. See the documentation on the Query.limit
method.
If you later want to get one or more additional documents, you'd use Query.startAfterDocument
passing in the document you already have. The query will then return documents after the so-called anchor document that you're passing in.
Upvotes: 1