How to exclude fields from being "upsert-ed" in Mongoose? How to exclude fields from being "upsert-ed" in Mongoose? mongoose mongoose

How to exclude fields from being "upsert-ed" in Mongoose?


Convert the document to an object and remove the property that you don't want to write. Then upsert the object.

this.upsert = function (doc) {    var object = doc.toObject();    delete object.isActive;    self.model.update({userID: object.userID}, object, {upsert: true}, function(err){...});};