Firebase - Firestore - 我将阅读文档多少次
Firebase - Firestore - how many time will I read documents
使用 Firebase 的新 Firestore,我发现我对 Observables 的了解很少。
我的问题如下:
我通过 db.collection('room') 获得了一些数据。
如果我不通过订阅收听 observable,我会获取文档吗? (我也这么认为)
对于我的集合 "room" 中的每个更改,它是否被 Firestore 视为 "new document read"?
如果我在我的应用程序中复制了 return db.collection('room') 的 Observables,我会调用 Firestore 数据库 X 次还是只有一次?
谢谢!
- If I don't listen to the observable with a subscription, do I fetch the document? (I think so).
当您调用 var ref = db.collection('room')
时,ref
并不是真正的可观察对象,它是对 'room'
collection 的引用。创建此引用不会执行任何数据读取(从网络或磁盘)。
当您调用 ref.get()
或 ref.onSnapshot()
时,您正在从服务器获取文档。
- For every change in my collection "room", is it considered as a "new document read" by Firestore?
如果您正在收听整个 collection(没有 where()
或 .orderBy()
条款)并且您有一个活跃的 onSnapshot()
听众那么是的,您将被收费对于每次在 collection.
中添加、更改或删除新文档时的文档读取操作
- If I have duplicated Observables which return db.collection('room') in my app, will I have X calls to the Firestore database or just one?
如果您在两个地方侦听相同的 Cloud Firestore 数据,您只需向服务器发出一次调用并为读取操作支付一次费用。将多个侦听器附加到一个引用没有 cost/performance 惩罚。
使用 Firebase 的新 Firestore,我发现我对 Observables 的了解很少。
我的问题如下:
我通过 db.collection('room') 获得了一些数据。
如果我不通过订阅收听 observable,我会获取文档吗? (我也这么认为)
对于我的集合 "room" 中的每个更改,它是否被 Firestore 视为 "new document read"?
如果我在我的应用程序中复制了 return db.collection('room') 的 Observables,我会调用 Firestore 数据库 X 次还是只有一次?
谢谢!
- If I don't listen to the observable with a subscription, do I fetch the document? (I think so).
当您调用 var ref = db.collection('room')
时,ref
并不是真正的可观察对象,它是对 'room'
collection 的引用。创建此引用不会执行任何数据读取(从网络或磁盘)。
当您调用 ref.get()
或 ref.onSnapshot()
时,您正在从服务器获取文档。
- For every change in my collection "room", is it considered as a "new document read" by Firestore?
如果您正在收听整个 collection(没有 where()
或 .orderBy()
条款)并且您有一个活跃的 onSnapshot()
听众那么是的,您将被收费对于每次在 collection.
- If I have duplicated Observables which return db.collection('room') in my app, will I have X calls to the Firestore database or just one?
如果您在两个地方侦听相同的 Cloud Firestore 数据,您只需向服务器发出一次调用并为读取操作支付一次费用。将多个侦听器附加到一个引用没有 cost/performance 惩罚。