My application uses Mongoose and has a schema that uses the timestamps option:
var fooSchema = new Schema({
name: String,
}, {
timestamps: true,
});
From mongoose 5 onwards , there is timestamps option which can be passed in Model.updateOne() and model.update() to skip timestamps for this update.
Directly from docs:
[options.timestamps=null] «Boolean» If set to false and schema-level timestamps are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
For example given in the question , timestamp updates can be skipped like this ,
Foo.updateOne({ __id: someFooId },{ $set: { name: updatedName } }, { timestamps: false });