Firebase 将Firestore batch.set()设置为同一文档是否与一个文档写入计数相同?
如果我在代码中这样做Firebase 将Firestore batch.set()设置为同一文档是否与一个文档写入计数相同?,firebase,google-cloud-platform,google-cloud-firestore,Firebase,Google Cloud Platform,Google Cloud Firestore,如果我在代码中这样做 function setShards(batch, docRef, numShards) { batch.set(docRef, { numShards } , { merge: true }); } const batch = firestore.batch(); batch.set(docRef, {data}); setShards(docRef, 10); batch.commit(); 如您所见,在执行.commit()之前,我正在
function setShards(batch, docRef, numShards) {
batch.set(docRef, { numShards } , { merge: true });
}
const batch = firestore.batch();
batch.set(docRef, {data});
setShards(docRef, 10);
batch.commit();
如您所见,在执行.commit()之前,我正在对同一文档进行batch.set。那么,这算是一个文档写入还是两个文档写入
谢谢。batch.set()不会直接花费任何文档写入成本。它只是在本地排队等待更改,然后再发送到Firestore。在成功调用batch.commit()
之前,不会进行计费。在这一点上,您将收取与整个批处理中的更改一样多的文档写入费用。因此,如果您在批处理中只写入一个文档,您将收取文档写入费用。batch.set()
不会直接花费任何文档写入费用。它只是在本地排队等待更改,然后再发送到Firestore。在成功调用batch.commit()
之前,不会进行计费。在这一点上,您将收取与整个批处理中的更改一样多的文档写入费用。因此,如果您在批处理中只编写一个文档,您将收取文档编写费用