What is the read/write cost for Firestore docRef.Collections(ctx)?

喜你入骨 提交于 2020-05-17 06:49:06

问题


I am tracking the read/write cost of my HTTP service layer functions.

Am I correct that Collection/Doc/Collection/Doc chains incur no reads?

reads := 0
bucketDocRef := s.fsClient.Collection("accounts").Doc(accountID).Collection("widgets").Doc(widgetID)
// no cost so far?

Also, what is the cost for a call to .Collections(ctx) ... is it 1 read for each collectionRef returned from iter.GetAll()?

iter := docRef.Collections(ctx)
colRefs, _ := iter.GetAll()
reads += len(colRefs)

Also, what is the cost if the call to iter.GetAll() results in an error?


回答1:


Collection and Document are just builder functions. They don't do anything other than build references to collections and documents. They are not actually performing any queries or reading any data, which means they are effectively "free" from the perspective of Firestore billing.

In your example, you won't be billed anything until you call GetAll, which costs 1 read per document returned, plus whatever egress is required.



来源:https://stackoverflow.com/questions/61640921/what-is-the-read-write-cost-for-firestore-docref-collectionsctx

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