问题
db.collection("cities").get().then(function(querySnapshot) {
console.log(querySnapshot.size); });
but the problem is I am using pagination and load 30 records for each call. so I am unable to get the total numbers of records. Is there any way to get it ? like, we are doing in sql.
回答1:
How to get the total number of records in a collection with Firebase ?
The method numChildren()
do that. You can find more information about it here
Here is an example to use it:
db.collection("cities").get().then(function(querySnapshot) {
console.log(querySnapshot.numChildren());
});
I hope my answer help you 😊
来源:https://stackoverflow.com/questions/53532615/firestore-how-to-get-the-total-number-of-records-in-a-collection-like-we-are-d