我一直注意到firestore中的读取量有所增加。我正在本地主机上测试我的应用程序。
今天,我决定仔细看看阅读量,并从零开始。我等待了大约3分钟,甚至没有运行我的应用程序或执行任何读取操作,我的读取次数上升到210次,2次写入。现在这一定很奇怪,知道应用程序甚至没有运行,当我启动的时候,它都是零。
我尽量避免使用onvalueChanges()和snapshotChanges(),因为它们会产生大量读操作。
下面是我在主页中调用的服务。
有谁知道这是怎么回事,并想分享一下吗?
提前谢谢。
export class CatService {
lastVisibleCat: any;
cats = [];
fecha = new Date().setHours(23, 59, 5, 9);
todaysDate = new Date(this.fecha);
constructor(public afs: AngularFirestore) {
}
getCats() {
const reference = this.afs.collection('Cats');
const query1 = reference.ref.where('timeStampEndDate', '>=',
this.todaysDate);
return query1.get().then(snapShot => {
snapShot.forEach(cat => {
this.cats.push({ ...cat.data(), id: cat.id });
});
return this.cats;
});
}
}发布于 2019-08-14 20:00:03
这里可能有几件事在起作用:
https://stackoverflow.com/questions/57491246
复制相似问题