简体   繁体   中英

How much i pay when use onSnapshot firestore?

So when i read realtime data use onSnapshot in collection with 1000 document, i will pay for 1000 read for first time i render the page.

Nah my question is, when someone add 1 new document to that collection, am i get charged only for read 1 new document or i get charged again for read 1000 document + 1 new document?

I read some post on this site about that, and also i read from firebase website in link below but i not really understand.

https://firebase.google.com/docs/firestore/pricing#listens

This post

Listening to query results

Cloud Firestore allows you to listen to the results of a query and get realtime updates when the query results change.

When you listen to the results of a query, you are charged for a read each time a document in the result set is added or updated. You are also charged for a read when a document is removed from the result set because the document has changed. (In contrast, when a document is deleted, you are not charged for a read.)

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.

My question is: when someone adds 1 new document to that collection, am I get charged only for read 1 new document or I get charged again for read 1000 document + 1 new document?

The answer is to be found in the second paragraph of the documentation excerpt you mention in your question:

When you listen to the results of a query, you are charged for a read each time a document in the result set is added or updated.

Listening to an entire collection is totally equivalent to listening to a query (the CollectionReference class extends the Query class), therefore when someone adds a new document to the collection, you are charged only for one document read .

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