I need to execute a cronjob function after some change has been done to one document in a collection
For example, when my user store is open , I need to launch a cronjob that will close that store at the time the user specifies, what I was thinking was something like this
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
});
});
Can I do this ?? Is there any way to do something like this ?
Thanks !