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 to Query.prototype.populate()
  • lean: if truthy, Mongoose will not hydrate any documents that are returned from this query. See Query.prototype.lean() for more information.
  • strict: controls how Mongoose handles keys that aren’t in the schema for updates. This option is true by default, which means Mongoose will silently strip any paths in the update that aren’t in the schema. See the strict mode docs for more information.
  • strictQuery: controls how Mongoose handles keys that aren’t in the schema for the query filter. This option is false by default for backwards compatibility, which means Mongoose will allow Model.find({ foo: 'bar' }) even if foo is not in the schema. See the strictQuery docs for more information.
  • useFindAndModify: used to work around the findAndModify() deprecation warning
  • omitUndefined: delete any properties whose value is undefined when casting an update. In other words, if this is set, Mongoose will delete baz from the update in Model.updateOne({}, { foo: 'bar', baz: undefined }) before sending the update to the server.
  • nearSphere: use $nearSphere instead of near(). See the Query.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.