Firestore:使用“where”查询集合,仅检索文档ID

时间:2018-04-17 14:31:08

标签: angular typescript firebase google-cloud-firestore angularfire2

我想查询firestore文档集合,并且只希望使用angularfire2检索文档ID,以节省读取所有文档的成本。 据我所知,以下代码也检索所有文档,并导致所有文档的读操作,无论我是否使用doc.data()。我是对的吗?

db.collection("cities").where("capital", "==", true).onSnapshot(function(querySnapshot) {
  querySnapshot.forEach(function(doc) {
    console.log(doc.id);
  }
});

所以在documentation中声明:

  

对于文档读取以外的查询,例如对列表的请求   收集ID,您需要为一份文件读取费用。

有没有办法使用angularfire2查询集合并只检索文档ID?

或者除了使用angularfire2之外还有其他方法吗?

0 个答案:

没有答案
相关问题