Edward Tanoto
Edward Tanoto

Reputation: 153

How does read from firebase works?

So for example, I fetched 100 collection from Firestore.

If I console.log the data from Firestore twice, does it still read as 100 or 200?

Upvotes: 1

Views: 42

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598847

A document read is charged when the document is read on the server on your behalf.

So:

  • When you read a document snapshot from the server to the client, you will be charged for that read.
  • When you read a document snapshot from the client's local cache, you won't be charged.
  • When you call data() on a document snapshot you are not charged, so you can call it multiple times without getting charged.

So: loading a DocumentSnapshot may be charged, depending on whether it requires a read from/on the server. Subsequently calling data() on that snapshot is not a charged operation.

Upvotes: 2

Related Questions