i have a collection "Store"
in that having number of documents
how i get the count of documents in that collection.
i have a collection "Store"
in that having number of documents
how i get the count of documents in that collection.
I believe there is no built in method for this but you can try this! First get all the documents in a List and then just get the size.
db.collection("Store")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
int count = 0;
for (DocumentSnapshot document : task.getResult()) {
count++;
}
} else {
Log.d(TAG, "Error getting documents: ", task.getException());
}
}
});