what could I do to make this code more beautiful?exports.index = function (req, res, next) {    Booking.aggregate(        [{            '$group': {                '_id': '$booking.date',                'name': {                    '$first': '$booking.name'                },                'participants': {                    '$sum': '$booking.participants'                },                'attended': {                    '$sum': {                        '$cond': [{                            '$eq': ['$attended', true]                        }, 1, 0]                    }                },                'bookings': {                    '$sum': 1                }            }        }, {            $sort: {                'booking.date': -1            }        }],        function (error, bookings) {            if (error) {                console.log(error);            }            else {                res.render('admin/bookings/index', {                    moment: moment,                    data: bookings,                });            }        }    );};exports.show = function (req, res, next) {    Booking.find({            'booking.date': req.params.id        })        .exec(function (error, booking) {            if (error) {                console.log(error);            }            else if (booking.length === 0) {                res.redirect('admin/reservas');            }            else {                res.render('admin/bookings/show', {                    moment: moment,                    data: booking,                });            }        });};exports.changeStatus = function (req, res, next) {    Booking.findById(req.params.id, function (error, booking) {        if (error) {            console.log(error);        }        else {            booking.update({                'attended': booking['attended'] === false ? booking['attended'] = true : booking['attended'] = false            }, function (error) {                if (error) {                    console.log(error);                }                else {                    res.end('Success!');                }            });        }    });};exports.destroy = function (req, res, next) {    Booking.remove({        _id: req.params.id    }, function (error) {        if (error) {            console.log(error);        }        else {            res.end('Success!');        }    });};
Booking program
javascript;node.js
Indention in JS is usually personal preference, but given that JS has a knack for nesting a lot of stuff... I suggest 2-space indents instead. Try to keep lines under 80 columns whenever possible. That way, people don't run off to the right.Try not to use _ and $ in key or variable names. While they are valid, it usually doesn't make sense. Also, for valid key values, '' is optional and since $ and _ are valid, then you can remove ''.I saw this code:'$cond': [{  '$eq': ['$attended', true]}, 1, 0]I don't know what the 1 and 0 are for. Better put them in keys instead. Also if 0 and 1 happen to be booleans, better use true and false instead to be more meaningful and we don't assume they are integers for some numeric purpose.cond: {  eq: {    attended: true  },  whateverOneIsFor: 1,  whateverZeroIsFor: 0,}if (booking.length === 0) is the same as if(!booking.length) since 0 is loosely equal to false.Not entirely sure but I think you just want to toggle'attended': booking['attended'] === false ? booking['attended'] = true : booking['attended'] = false// is the same as'attended': booking['attended'] = !booking['attended']