Reputation: 590
How firestore read is counting when I only get the documents size of a collection? For Example if i run this query
Firebase.firestore.collection("student").addSnapshotListener { value, error ->
val size = value?.documents?.size?
}
It is couting as all documents or 1?
Upvotes: 1
Views: 184
Reputation: 317352
This code is going to cause your project is going to be billed one read for each document in the student collection.
It doesn't matter what you do inside the listener callback. Once you execute that query, the documents will be read and downloaded to your app. The callback is delivered the entire set of results. For the purpose of billing, it doesn't matter what you do with the results at that point, since everything is in memory.
If you want a less expensive way of getting a count of documents in a collection, you will need to manage that yourself. Read this: Cloud Firestore collection count
Upvotes: 2