I'm facing a strange issue with Mongoose Update, and I don't know where to search anymore...
I would like to update a document (I want to update because I need to exclude validation) from a model method. This is my code:
module.exports.plugin = function(schema){ schema.add( { deletedAt : { type : Date, default: null } }); schema.methods.softDelete = function(done){ this.update({_id: this._id}, {deletedAt: new Date()}, function(err, num, raw){ logger.info(err, 'Number Updated: ' + num); logger.info(raw); done(err, num); }); }; }; The function is correctly triggered, this is the output of the logger:
Number Updated: 1 (ok=true, n=1, updatedExisting=true) that made me suppose that everything works, but then (checking directly in mongo) the field deletedAt has not been updated.
Any suggestions?
Thanks in advance
deletedAtproperty?schema.add( { deletedAt : { type : Date, default: null } });