Home > Enterprise >  Regarding transactions in Firestore, if I write to the same document multiple times, will those oper
Regarding transactions in Firestore, if I write to the same document multiple times, will those oper

Time:09-10

If I update fieldA of my document and then later in the same transaction update fieldB, how many writes will this get counted as when I commit the transaction?

CodePudding user response:

If I update fieldA of my document and then later in the same transaction update fieldB, how many writes will this get counted as when I commit the transaction?

If you do the update operations, one after another, meaning that you call update() function two times, then you'll have to pay two write operations. However, as @Dharmaraj mentioned in his comment, you can update as many fields as you want, in a single update, and pay a single read.

However, if the second update is based on the processing of the first update, then yes, you'll have to pay two writes.

  • Related