I am trying to paginate the "messages" collection query using limit.
_chatReference
.orderBy('createdAt', descending: true)
.limit(limit)
.snapshots()
.doOnListen(() => print('Chat stream started with limit $limit'))
.doOnCancel(() => print('Chat stream cancelled for limit $limit'))
As soon as the user reaches the scroll end I am increasing the limit. But when I increase the limit do I get charged for the last limit + new limit or just the new limit?
Ex- If I call the query with the limit of 20 and then increase it to 40 what is the total read count? Is it 40 or 60?
What if the query stream with a limit of 20 cancelled before listening to the stream with a limit of 40?
If you say that when you first time launch the app, you're getting 20 documents, then you'll be charged with 20 document reads. If you increase the limit from 20 to 40, this means that you'll be charged with 20 more document reads. So there will be a total of 40 reads. You won't be charged again with the initial 20 reads, because those 20 documents are already in the cache.
Be aware that this mechanism works, only if you're attaching a real-time listener. If you intent to use a get()
call, you'll be charged for document reads each time you perform a query.