I have set up a cron job using the npm package cron. I am trying to do the following Coll.find().forEach
function but I am getting the error Error: Can't wait without a fiber
var job = new CronJob({
cronTime: '00 09 11 * * 1-5',
onTick: function() {
var userIds = []
Coll.find().forEach(function(doc) {
userIds.push(doc._id)
});
},
start: false,
timeZone: "Europe/London"
});
job.start();
I have been using npm packages fibers and future library. I still got the same error.
var resultOne = collFind();
function collFind() {
var f = new future()
var userIds = []
Coll.find().forEach(function(doc) {
userIds.push(doc.userId)
});
return f['return']({userIds:userIds}
return f.wait()
}