简体   繁体   中英

Firebase Firestore snapshot read count

I am trying to optimize the number of reads my app makes on Firesbase and reviewing the way I use snapshot to monitor real time changes. Imagine I have a snapshot returning the 10 latest documents like the following:

db.collection("cities")
.where("state", "==", "CA").
.orderBy('dateadded', 'desc').limit(10)
.onSnapshot(function(snapshot) {
    ...
})

The doc says

The snapshot handler will receive a new query snapshot every time the query results change (that is, when a document is added, removed, or modified).

Does that mean that every time the query changes I will be billed 10 reads? In this example if a new city is added (so with the latest 'dateadded', so coming first in the query) will it be 1 (just the new city) or 10 reads (the full query).

As a side question where I can see the exact number of read I am at (live so I can test a function and see the corresponding number of reads). The IAM and Admin/Quota seems to provide that under "reads request per day" but it is not live...

I am referring to the Firestore snapshot as described at https://firebase.google.com/docs/firestore/query-data/listen

If 1 document changes in query results, you will be billed 1 read. You are not billed for documents that are unchanged. The query snapshot object merely reuses the document data that was in memory from the prior set of results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM