const Order = require('../models/Order');

exports.removeOldOrders = (req, res) => {
    var date = new Date();
    date.setDate(date.getDate() - 2); // two days old

    Order.remove({$and: [
        {isCheckedout: false},
        {updatedAt: {$lte: date}}
        ]}, (err) => {
            if (err) {
                console.log('There was an error when removeOldOrders'+err.message)
            } else {
                console.log('Successfully cleaned old orders (Not checkedout)')
            }
    });
}

exports.removeOldOrdersCheckedoutNotPayed = (req, res) => {
    var date = new Date();
    date.setDate(date.getDate() - 15); // fifhteen days old

    Order.remove({$and: [
        {isCheckedout: true},
        {email: {$exists: false}},
        {updatedAt: {$lte: date}}
        ]}, (err) => {
            if (err) {
                console.log('There was an error when removeOldOrders'+err.message)
            } else {
                console.log('Successfully cleaned old orders (Not checkedout)')
            }
    });
}
@@ -983,37 +983,33 @@
 ned old orders (
-Not c
+C
 heckedout)')%0A   
@@ -1008,28 +1008,29 @@
 t)')%0A            %7D%0A    %7D);%0A%7D
+%0A

Update cronJobs.js