Javascript 如何在任何集合的onWrite之后部署cron作业云函数

Javascript 如何在任何集合的onWrite之后部署cron作业云函数,javascript,google-cloud-firestore,google-cloud-functions,scheduled-tasks,cron-task,Javascript,Google Cloud Firestore,Google Cloud Functions,Scheduled Tasks,Cron Task,下面是运行cron作业的代码 exports.cronJob = functions.pubsub.schedule('5 11 * * *') .timeZone('America/New_York') // Users can choose timezone - default is America/Los_Angeles .onRun((context) => { console.log('This will be run every day at 11:05 AM Ea

下面是运行cron作业的代码

exports.cronJob = functions.pubsub.schedule('5 11 * * *')
  .timeZone('America/New_York') // Users can choose timezone - default is America/Los_Angeles
  .onRun((context) => {
  console.log('This will be run every day at 11:05 AM Eastern!');
  return null;
});
但我想在系统中检测到任何更改时运行cron作业

exports.changeDetected = functions.firestore
  .document('/myTable/{myID}')
  .onWrite((snapshot, context) => {
    const dataAfterWrite = snapshot.after.data();
    const myID = context.params.myID;
    /*I want to deploy a cron job cloud function from here with the name of myID. something like this:

  exports.{$`myID`} = functions.pubsub.schedule('5 11 * * *')
  .timeZone('America/New_York') // Users can choose timezone - default is America/Los_Angeles
  .onRun((context) => {
  console.log('This will be run every day at 11:05 AM Eastern!');
  return null;
});
 */      
    return true;
  });

在firebase云函数中有可能做到这一点吗?当检测到任何集合中的任何更改时,我们是否可以部署firebase cron作业云函数?

让一个函数动态部署另一个函数实际上是不可行的。我建议创建一个周期性运行的函数,让它检查在触发时应该做什么工作。这项工作可以使用Firestore中的文档来描述,因此您所要做的就是查询这些文档,并根据您发现的内容采取行动。

那么,当检测到任何集合中的更改时,我们可以部署firebase crone作业云功能吗?我说这是不可行的。