Firestore onSnapshot -> Does it work for subcollections?

旧街凉风 提交于 2021-01-01 06:45:26

问题


Is the method onSnapshot of firestore triggered by any changes in subcollections?

What is the difference between db.firestore.collection('x'). onSnapshot

And db.firestore.collection('x').doc('y').collection('z'). onSnapshot

Are they equal????


回答1:


A change to a subcollection organized under a document do not count as changes to the document itself. They will not trigger a snapshot event on that document.

Listening to a subcollection is not any different than listening to a top-level collection. In both cases, the listener will only be triggered by changes to documents within that collection or subcollection.



来源:https://stackoverflow.com/questions/52309507/firestore-onsnapshot-does-it-work-for-subcollections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!