【发布时间】:2020-08-14 19:44:48
【问题描述】:
在对集合中的一个文档进行一些更改后,我需要执行一个 cronjob 函数
例如,当我的用户商店打开时,我需要启动一个 cronjob 来在用户指定的时间关闭该商店,我的想法是这样的
exports.updateUser = functions.firestore
.document('stores/{storeId}')
.onUpdate((change, context) => {
//Logic to get the store close time here, lets say I get close in 4 hours
//Now here I plan to run a cronjob like this
exports.scheduledFunctionCrontab = functions.pubsub.schedule('* 4 * * *')
.timeZone('America/New_York') // Users can choose timezone - default is America/Los_Angeles
.onRun((context) => {
//Close my store in 4 hours
});
});
我可以这样做吗?有没有办法做这样的事情?
谢谢!
【问题讨论】:
标签: javascript android firebase google-cloud-functions