Query.prototype.mongooseOptions()
Parameters
- options «Object» if specified, overwrites the current options
Returns:
- «Object» the options
Getter/setter around the current mongoose-specific options for this query Below are the current Mongoose-specific options.
populate
: an array representing what paths will be populated. Should have one entry for each call toQuery.prototype.populate()
lean
: if truthy, Mongoose will not hydrate any documents that are returned from this query. SeeQuery.prototype.lean()
for more information.strict
: controls how Mongoose handles keys that aren’t in the schema for updates. This option istrue
by default, which means Mongoose will silently strip any paths in the update that aren’t in the schema. See thestrict
mode docs for more information.strictQuery
: controls how Mongoose handles keys that aren’t in the schema for the queryfilter
. This option isfalse
by default for backwards compatibility, which means Mongoose will allowModel.find({ foo: 'bar' })
even iffoo
is not in the schema. See thestrictQuery
docs for more information.useFindAndModify
: used to work around thefindAndModify()
deprecation warningomitUndefined
: delete any properties whose value isundefined
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.nearSphere
: use$nearSphere
instead ofnear()
. See theQuery.prototype.nearSphere()
docs
Mongoose maintains a separate object for internal options because Mongoose sends Query.prototype.options
to the MongoDB server, and the above options are not relevant for the MongoDB server.
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .