简体   繁体   中英

passing an extra parameter in jobschedule in node.js

Is there any possible way to pass any extra parameter instead of date in schedule.scheduleJob(date,function(id))

The below code is not working

var id =record.id;
  var date =record.date;


    jobsCollection.save({
     id: record.id
 }, {
     $set: record
 }, function (err, result) {
     var j = schedule.scheduleJob(date, function (id) {
         return function () {
             console.log("inside----------")
             console.log(id)
         };

     }(id));
     if (!err) {
         return context.sendJson([], 404);;
     }


 });

i want to pass the date along with another data to schedule jobs. so that i can perform other operations based on the date schedul e and that id

schedule.scheduleJob() accepts three parameters.So you can pass id as one of the parameter

var id =record.id;
  var date =record.date;


jobsCollection.save({
 id: record.id
 }, {
     $set: record
 }, function (err, result) {
     var j = schedule.scheduleJob(id,date, function () {
        console.log(id) //this will prints your id

     });
     if (!err) {
         return context.sendJson([], 404);;
     }


 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM