【发布时间】:2021-02-03 20:25:28
【问题描述】:
我是这样设置云功能的:
exports.changeIsVisibleFieldAfterDay = functions.pubsub
.schedule("every 2 minutes").onRun((context) => {
const d = new Date();
d.setDate(d.getDate() - 1);
return db.collectionGroup("Moments")
.where("isVisible", "==", true)
.where("timestamp", "<=", d)
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
Promise.all().doc.ref.update({isVisible: false}, {merge: true});
});
return null;
});
});
当我插入 Promise.all() 以更新子集合中的所有文档时,我收到此错误:
TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at Function.all (<anonymous>)
当我不使用Promise.all() 时,文档会正确更新,但我知道如果我想更新大量文档,我需要Promise。
【问题讨论】:
标签: firebase google-cloud-firestore google-cloud-functions