Of course, I can know how to get the number of docs by the following code:
handledocsNumber(){
Future<QuerySnapshot<Map<String, dynamic>>> number = FirebaseFirestore.instance.collection("users").get();
number.then((value) {
int docsNumber = value.docs.length;
});
}
But it sounds horrifying way if the collection has huge docs because .get()
will consider the whole docs as new reads special if this method was continuously for User's purposes. I just imagine docs were 100.000, that's mean .get()
will always read 100.000 docs as new read every time the user need to know the length.
any good way to know the length by only paying for one query process which is the length process?