我想在发生事件时使用 Cloud Functions 在 Firestore 中复制一个集合
我已经有这段代码可以遍历集合并复制每个文档
const firestore = admin.firestore()
firestore.collection("products").get().then(query => {
query.forEach(function(doc) {
var promise = firestore.collection(uid).doc(doc.data().barcode).set(doc.data());
});
});
有更短的版本吗?一次复制整个集合?
原文由 Khaled 发布,翻译遵循 CC BY-SA 4.0 许可协议
目前,没有。使用 Cloud Functions 循环遍历每个文档,然后将新文档设置为具有指定数据的不同集合是执行此操作的唯一方法。也许这会提出一个很好的功能请求。
我们在谈论多少份文件?对于像 10,000 这样的东西,最多只需要几分钟。