【发布时间】:2022-01-28 19:03:15
【问题描述】:
我在云函数中有这种情况。条件是,如果该值为“true”,那么我需要在 5 分钟后将其安排为 false。状态将更新为 true,但 5 分钟后仍保持为 true。
if(status == true){
let usersUpdate = {};
usersUpdate[`machines.${on}.status`] = true;
db.collection('customers').doc(doc.id)
.update(usersUpdate);
//wait for 5 minutes
//change status to false
schedule = functions.pubsub.schedule('every 5 minute').onRun((context) => {
console.log('This will be run every 5 minutes!');
let usersUpdate = {};
usersUpdate[`machines.${on}.status`] = false;
db.collection('customers').doc(doc.id)
.update(usersUpdate);
})}
但这不起作用。我应该导出 pubsub 函数吗?
【问题讨论】:
标签: node.js firebase google-cloud-firestore google-cloud-functions