Query.prototype.setOptions()
Parameters
- options «Object»
Returns:
- «Query» this
Sets query options. Some options only make sense for certain operations.
Options:
The following options are only for find()
:
The following options are only for write operations: update()
, updateOne()
, updateMany()
, replaceOne()
, findOneAndUpdate()
, and findByIdAndUpdate()
:
- upsert
- writeConcern
- timestamps: If
timestamps
is set in the schema, set this option tofalse
to skip timestamps for that particular update. Has no effect iftimestamps
is not enabled in the schema options. - omitUndefined: 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. - overwriteDiscriminatorKey: allow setting the discriminator key in the update. Will use the correct discriminator schema if the update changes the discriminator key.
- overwrite: replace the entire document
The following options are only for find()
, findOne()
, findById()
, findOneAndUpdate()
, and findByIdAndUpdate()
:
The following options are only for all operations except update()
, updateOne()
, updateMany()
, remove()
, deleteOne()
, and deleteMany()
:
The following options are for findOneAndUpdate()
and findOneAndRemove()
- useFindAndModify
- rawResult
The following options are for all operations
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .