Firestore pricing; need help understanding a phrase in the document

冷暖自知 提交于 2021-02-08 06:13:16

问题


I came across the phrase below in Firestore help document which got me confused.

"Also, if the listener is disconnected for more than 30 minutes (for example, if the user goes offline), you will be charged for reads as if you had issued a brand-new query."

  1. Does this mean that if I disconnect a listener and connect again within 30 minutes, I won't be charged for reads after connecting listener again? Imagine if I reconnect query and retrieve 20 documents again in (change.type === "added").

    db.collection("cities").where("state", "==", "CA")
        .onSnapshot(function(snapshot) {
            snapshot.docChanges.forEach(function(change) {
    
            //imagine 20 documents are fetched when I listen.
                if (change.type === "added") {
                    console.log("New city: ", change.doc.data());
                }
     });
    });
    

Am I confused or the phrase is confusing? (or.. have I found a loophole? lol)


回答1:


The issue isn't wither you choose to disconnect the listener and reconnect a new one. The issue is if the listener becomes disconnected through some means out of your control, such as network unavailability.

Think about how expensive your query might be if the user's device is on a very spotty connection whose availability comes and goes frequently. The point is to acknowledge that you shouldn't have to pay for those conditions outside your control.

But if you're just going to repeatedly querying your database, well, you should be paying for that.



来源:https://stackoverflow.com/questions/48481680/firestore-pricing-need-help-understanding-a-phrase-in-the-document

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