Lodash _.extend not extending a nested object Lodash _.extend not extending a nested object mongoose mongoose

Lodash _.extend not extending a nested object


If you're using a Mongoose model with lodash then you'll need to first aggregate your data before assign it.

For example:

var data = _.merge(dest.toJSON(), src);  _.extend(dest, data);  dest.save();  

This is likely because Mongoose models attach additional non-enumerable/configuration to the object that causes problems during extend/merge.