Facing an issue with calculating the Firestore read count as it keeps increasing rapidly even with only around 15 user documents. The count surges by 100 with each page reload and sometimes increases on its own without any action from me. Could this be due to a subscription behavior causing data reads to refresh periodically? (I've come across suggestions to use "once" for one-time data extraction).
Below is the TypeScript code snippet:
// 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 if image does not exist.
ref = this.store.ref('images/ironman.jpg');
}
await ref.getDownloadURL().toPromise().then(urlString => {
result.profileURL = urlString;
// Convert availability 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 exactly does the firestore read count function? Is the increment based on document queries and does it continue querying itself after a certain period? Firestore read count exceeds number of user documents