I have encountered some issue when trying to figure out and calculate the firestore read count. The firestore read count is always surging up at a very high rate (100 counts increment every time I reload the page) even though there are only around 15 users documents. Even when I am not reloading the page, the firestore read count would go up itself, is this due to the subscribe behaviour that cause the read data action refreshing from time to time? (I have read some articles recommend to use "once" if user want to extract data just once).
Bellow is the code snippet (ts):
// All buddy users from Firebase
private usersCollection: AngularFirestoreCollection<Profile>;
users: Observable<Profile[]>;
usersFirebase: Profile[] = [];
getUserDataFromFirebase() {
this.isImageLoading = false;
this.users.subscribe(async results => {
var ref;
for(let result of results) {
if(result.imageName) {
ref = this.store.ref('images/' + result.userId + '/profiles/' + result.imageName);
} else {
// Get default image is image not existing
ref = this.store.ref('images/ironman.jpg');
}
await ref.getDownloadURL().toPromise().then(urlString => {
result.profileURL = urlString;
// Change availibility date from timestamp to date format
try {
result.availability = this.datePipe.transform(result.availability.toDate(), 'yyyy-MM-dd');
} catch (error) {}
result.flip = 'inactive';
if(result.identity == 'Tenant')
{
this.usersFirebase.push(result);
}
return new Promise((resolve, reject) => {
resolve();
})
});
}
console.log(this.usersFirebase);
});
}
How does the firestore read count works, is the count increment based on document queries, will it continue to query itself after a certain amount of time? Firestore read count increases more than users documents