firebase - 事务中单个文档的多次更新是否会在 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)
}
}
解决方案
它被认为是一个单独的写操作。最好将它们结合起来。我想这会对你有所帮助。关联
推荐阅读
- delphi - 取消 FMX TWebBrowser 的导航
- c# - 使用回调模拟 Azure CloudFile DownloadToStream 方法不起作用
- c# - 加密 app.config 以在另一台计算机上使用的最佳方法
- python - 没有OUTPUT的MySQL过程,从python获取所有结果
- android - Android - NestedScrollView 内的 RecyclerView - 如何以给定的偏移量(到 NestedScrollView 的顶部)带来指定的适配器位置?
- excel - macOS 沙盒阻止 Excel VBA 访问 NAS 上的图像
- python - Plotly 雷达图 - 变量引用作为值
- angular - FormBuilder 的数据从选择器变慢
- visual-studio - mac Osx上的大括号VS代码
- sql-server - T-SQL 对多列上的值进行分组并将行值作为列返回