Reputation: 33
How many read in firebase if under one await I run a loop and I have 20 documents in total but my loop will filter out some after checking. After checking it will take 10 data. But for taking, it needs to read 20 documents. So how many read will it count? I heard one await one read. But my firebase dashboard is showing 5/6 times more. In the picture i have shown the code. please tell me how many read will it count?
Future getUser() async {
final id = await FirebaseAuth.instance.currentUser();
userId=id.uid;
await Firestore.instance.collection('user').getDocuments().then((users) {
print("loop running");
for (var user in users.documents) {
if ((!seenList1.contains(user.documentID)) &&
(!chosenList1.contains(user.documentID)) &&
(!showId1.contains(user.documentID)) &&
(user.documentID != userId) &&
("male" == user['gender'])
) {
loc(user['Location'].latitude, user['Location'].longitude).then((result){
if(result==true){
setState(() {
showId1.add(user.documentID) ;
showName1.add(user['name']) ; }
});
}
}
});
return ;
}
Upvotes: 0
Views: 260
Reputation: 600090
The call to getDocuments()
determines how many documents are read. So in your case:
Firestore.instance.collection('user').getDocuments()
This means that all documents from the user
collection are read. If those documents are not in the local cache of the device yet, Firestore will have to read them on the server and return them to the client.
So say your cache is empty: that'd mean that you're charged a read for each document in the user
collection, and the total bandwidth that is used for downloading those documents.
Upvotes: 1