Lodash merge with mongoose
问题 Here is a code snippet of an update method using express.js and mongoose. I'm trying to merge the existing mongo entity with the json object from the request payload body. exports.update = function(req, res) { if(req.body._id) { delete req.body._id; } Entity.findById(req.params.id, function (err, entity) { if (err) { return handleError(res, err); } if(!entity) { return res.send(404); } var updated = _.merge(entity, req.body); updated.save(function (err) { if (err) { return handleError(res,