问题描述
我正在使用 google 的 firestore,我想获得整个集合的实时更新.
I'm using google's firestore and I want to get a live update on the entire collection.
我在文档中看到了这一点:https://cloud.google.com/nodejs/docs/reference/firestore/0.11.x/CollectionReference#onSnapshot
I saw this in the documents:https://cloud.google.com/nodejs/docs/reference/firestore/0.11.x/CollectionReference#onSnapshot
但据我所知,我必须获取一个文档或查询一系列文档.
but as far as I understood I have to get a document or to query a range of documents.
如何监听整个集合的变化?
how can I listen to changes in the entire collection?
推荐答案
如果您参考 收听集合中的多个文档 文档,只需省略 where 过滤器,您就应该获得整个集合.
If you refer back to the Listen to multiple documents in a collection documentation, simply omit the where filter and you should get the whole collection.
第一行看起来像这样:var query = db.collection("cities");
这篇关于firestore - 收听整个收藏的更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!