From Android example in documentation, it is clear that we can update multiple fields in a single update() call. I was wondering, does this call cost one write or n writes (n = the number of fields updated)?
// Assume the document contains:
// {
// name: "Frank",
// favorites: { food: "Pizza", color: "Blue", subject: "recess" }
// age: 12
// }
//
// To update age and favorite color:
db.collection("users").document("frank")
.update(
"age", 13,
"favorites.color", "Red"
);
What is the cost of updating multiple fields in a single call?
It will always cost a single write, no matter how many fields you update in a single update() call.
Update should be counted in writes, ofcourse.
I had started using Firestore again for my new project yesterday and did 2 write operations.
I created 2 new documents with multiple fields and it costed me 2 writes.
Then I updated 2 fields in a single document it costed me only 1.
So the answer is, it should cost you only 1 write.
The write count remains 1 irrespective of number of fields in a single document update() or write().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With