I want my function to run once a day, but twice on weekends. How do I do that with Firebase?
My crontabs:
From what I know, my only chooce is to create another instance of the same function with a different crontab. Is there a better way?
Thanks
From what I know, my only choice is to create another instance of the same function with a different crontab. Is there a better way?
Yes, this is the only solution. However you can put the "main" code in one function, as follows:
exports.scheduledFunction1 = functions.pubsub.schedule('...').onRun(async (context) => {
try {
await mainFunction();
return null;
} catch (error) {
console.log(error);
return null;
}
});
exports.scheduledFunction2 = functions.pubsub.schedule('...').onRun(async (context) => {
try {
await mainFunction();
return null;
} catch (error) {
console.log(error);
return null;
}
});
async function mainFunction() {
//await ...
}