Document.prototype.updateOne()
Parameters
- doc «Object»
[options] «Object» optional see
Query.prototype.setOptions()
[options.lean] «Object» if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See
Query.lean()
and the Mongoose lean tutorial.[options.strict] «Boolean|String» overwrites the schema’s strict mode option
[options.omitUndefined=false] «Boolean» If true, delete any properties whose value is
undefined
when casting an update. In other words, if this is set, Mongoose will deletebaz
from the update inModel.updateOne({}, { foo: 'bar', baz: undefined })
before sending the update to the server.[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.callback «Function»
Returns:
- «Query»
Sends an updateOne command with this document _id
as the query selector.
Example:
weirdCar.updateOne({$inc: {wheels:1}}, { w: 1 }, callback);
Valid options:
- same as in Model.updateOne