TriangleN
TriangleN

Reputation: 337

What counts as a read in Firestore?

What counts as a read in Firestore:

db.collection("Collection").document(id).get()

OR:

db.collection("Collection").document(id).get().addOnCompleteListener { task ->
 task.result.get("field")
 task.result.get("field")
 task.result.get("field")
 task.result.get("field")
}

Upvotes: 0

Views: 28

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 50930

Both. You are calling .get() method so that makes a call to Firestore servers (if offline persistence is not enabled or document is not found in cache). Just creating the DocumentReference however does not charge:

// just a reference, document data not fetched
db.collection("Collection").document(id)

In the 2nd code snippet, the task.result seems to be fetched data and you are just read a single field locally.

Upvotes: 2

Related Questions