[英]Regarding transactions in Firestore, if I write to the same document multiple times, will those operations get flattened to a single write?
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?如果我更新我的文档的fieldA
,然后在同一个事务中更新fieldB
,那么当我提交事务时,这将被计算为多少次写入?
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?如果我更新我的文档的字段 A,然后在同一个事务更新字段 B 中更新,那么当我提交事务时,这将计算多少次写入?
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.如果你一个接一个地进行更新操作,这意味着你调用 update() function 两次,那么你将不得不支付两次写入操作。 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.但是,正如@Dharmaraj 在他的评论中提到的那样,您可以在一次更新中更新任意数量的字段,并支付一次阅读费用。
However, if the second update is based on the processing of the first update, then yes, you'll have to pay two writes.但是,如果第二次更新基于第一次更新的处理,那么是的,您必须支付两次写入费用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.