This is similar,
But I have a collection, depending on moment().Date() I will implement associate logic that sends
start job to machine 1, and then sends end job to machine 1
start job to machine 2, and then sends end job to machine 2
and so on, but how to remove rows without id when old rows have already expired?
id task start_date end_date
0 12345 2016-05-10 2016-05-12
1 56789 2016-05-11 2016-05-18
etc
FutureTasks.find().forEach(function (details) {
if (moment(details.start_date) > moment().toDate()) {
//Do Nothing
} else if ( moment(details.start_date) < moment().toDate() &&
moment(details.end_date) > moment().toDate() ) {
console.log('send start_task');
}
else if ( moment(details.start_date) < moment().toDate() &&
moment(details.end_date) < moment().toDate() ) {
console.log('send end_task');
// <- How to remove old row without _id?
}
else {
console.log('end');
}
//Old expired tasks not removed???
FutureTasks.remove({
end_date: {$gt: new Date()},
});
console.log('end of ACS task, nothing detected in collection');