Sush
Sush

Reputation: 1457

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 schedule and that id

Upvotes: 2

Views: 2767

Answers (1)

divz
divz

Reputation: 7957

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);;
     }


 });

Upvotes: 7

Related Questions