Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 将Firestore batch.set()设置为同一文档是否与一个文档写入计数相同?_Firebase_Google Cloud Platform_Google Cloud Firestore - Fatal编程技术网

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()
之前,不会进行计费。在这一点上,您将收取与整个批处理中的更改一样多的文档写入费用。因此,如果您在批处理中只编写一个文档,您将收取文档编写费用