我正在从Firestore提取数据,但卡在一个地方。我需要获取值等于doc集合的特定数据。请看图片
如您所见,我在文档中有categoryID。所以我需要所有在其文档中具有此值的文档。任何快速解决方案,我该怎么做?
这是我的简单代码,我正在以此获取所有问题,但需要通过categoryID进行查找
public getQuestions(): Observable<{}[]> {
return this.angularFirestore.collection("questions").valueChanges();
}
您需要查询例如:
public getQuestions(): Observable<{}[]> {
return this.angularFirestore.collection("questions", ref => ref.where('categoryID', '==', id_here)).valueChanges();
}
在此处查看有关angularfire的更多信息:
https://github.com/angular/angularfire/blob/master/docs/firestore/querying-collections.md