事务中单个文档的多次更新是否会在 Firestore 中分别产生每次更新的写入成本

Does multiple updates on single document in a transaction incur write cost for each update separately in Firestore

例如 update(sfDocRef, "population", newPopulation)update(sfDocRef, "count", newCount)算作单独文件写入。或者我应该使用 set() 方法


db.runTransaction { transaction ->
    val snapshot = transaction.get(sfDocRef)

    val newPopulation = snapshot.getDouble("population")!! + 1
    val newCount = snapshot.getLong("count")!! + 1
    it.apply {
         update(sfDocRef, "population", newPopulation)
         update(sfDocRef, "count", newCount)
    }  
}

它被认为是一个单独的写操作。最好将它们结合起来。我想这会对你有所帮助。