【问题标题】:Multiple firestore fieldvalue increments on single document billable write count单个文档计费写入计数上的多个 Firestore 字段值增量
【发布时间】:2021-03-30 23:54:51
【问题描述】:

如果我有以下情况:

const admin = require('firebase-admin')
const batch = admin.firestore().batch();
 const counterRef = admin
    .firestore()
    .collection(COLLECTIONS.counters)
    .doc('daily_counters')
batch.set(counterRef, {
counter_a: admin.firestore.FieldValue.increment(1),
counter_b: admin.firestore.FieldValue.increment(1),
counter_c: admin.firestore.FieldValue.increment(1)
}, { merge: true });
batch.commit();

在计费方面,以上是否算作 3 次写入或 1 次写入?

【问题讨论】:

    标签: node.js firebase google-cloud-firestore firebase-admin


    【解决方案1】:

    一次写入,因为它写入一个文档。您甚至不需要批处理,因为它只是一个文档。单个设置/更新将具有相同的效果。使用批处理的主要原因是同时以原子方式写入多个文档,或者如果任何失败则完全回滚。

    【讨论】:

      猜你喜欢
      • 2018-10-04
      • 2021-07-18
      • 1970-01-01
      • 1970-01-01
      • 2020-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多