Using current version of MassiveJS and express for API calls. When using the SAVE function, Massive wants a list of column names to update as follows:
router.put('/:id', function(req, res, next) {
db.suppliers.save(
{
id: +req.params.id,
name: req.body.name,
email: req.body.email,
column1: req.body.column1,
column2: req.body.column2,
column3: req.body.column3,
manyOtherColumns: req.body.manyOtherColumns,
etc...
}, function (err, result) {
if (err) {
return next(err);
}
return res.status(200).json({
status: 'SUCCESS',
message: 'Supplier has been saved'
});
})
});
As you can see, as the column list getting longer and longer, this code becomes more difficult to maintain. So I was wondering if there is a way to save the entire req.body in a single call assuming that the req.body key values match the db column names. That would save A LOT of time and be far more maintainable.