Skip to content

Commit

Permalink
docs(model+query): add lean() option to Model helpers
Browse files Browse the repository at this point in the history
Fix #5996
  • Loading branch information
vkarpov15 committed Jan 20, 2018
1 parent b19aa23 commit d7232de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,7 @@ Model.$where = function $where() {
* @param {Object} [conditions]
* @param {Object} [update]
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](http://mongoosejs.com/docs/api.html#query_Query-setOptions)
* @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](http://mongoosejs.com/docs/api.html#query_Query-lean).
* @param {Function} [callback]
* @return {Query}
* @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
Expand Down Expand Up @@ -1805,6 +1806,7 @@ Model.findOneAndUpdate = function(conditions, update, options, callback) {
* @param {Object|Number|String} id value of `_id` to query by
* @param {Object} [update]
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](http://mongoosejs.com/docs/api.html#query_Query-setOptions)
* @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](http://mongoosejs.com/docs/api.html#query_Query-lean).
* @param {Function} [callback]
* @return {Query}
* @see Model.findOneAndUpdate #model_Model.findOneAndUpdate
Expand Down Expand Up @@ -2968,7 +2970,8 @@ Model.aggregate = function aggregate() {
* - `lean` {Boolean} return the raw object instead of the Mongoose Model
*
* @param {Object} conditions an object that specifies the match condition (required)
* @param {Object} options for the geoSearch, some (near, maxDistance) are required
* @param {Object} [options] for the geoSearch, some (near, maxDistance) are required
* @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](http://mongoosejs.com/docs/api.html#query_Query-lean).
* @param {Function} [callback] optional callback
* @return {Promise}
* @see http://docs.mongodb.org/manual/reference/command/geoSearch/
Expand Down
4 changes: 2 additions & 2 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -1002,11 +1002,11 @@ Query.prototype.read = function read(pref, tags) {
* - [readPreference](http://docs.mongodb.org/manual/applications/replication/#read-preference)
* - [hint](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint)
*
* The following options are only for `update()`, `updateOne()`, `updateMany()`, `replaceOne()`, and `findOneAndUpdate()`:
* The following options are only for `update()`, `updateOne()`, `updateMany()`, `replaceOne()`, `findOneAndUpdate()`, and `findByIdAndUpdate()`:
* - [upsert](https://docs.mongodb.com/manual/reference/method/db.collection.update/)
* - [writeConcern](https://docs.mongodb.com/manual/reference/method/db.collection.update/)
*
* The following options are only for `find()`, `findOne()`, `findById()`, and `findOneAndUpdate()`:
* The following options are only for `find()`, `findOne()`, `findById()`, `findOneAndUpdate()`, and `findByIdAndUpdate()`:
* - [lean](./api.html#query_Query-lean)
*
* The following options are only for all operations **except** `update()`, `updateOne()`, `updateMany()`, `remove()`, `deleteOne()`, and `deleteMany()`:
Expand Down
12 changes: 6 additions & 6 deletions test/docs/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,12 @@ describe('validation docs', function() {
* One final detail worth noting: update validators **only** run on the
* following update operators:
*
* \* `$set`
* \* `$unset`
* \* `$push` (>= 4.8.0)
* \* `$addToSet` (>= 4.8.0)
* \* `$pull` (>= 4.12.0)
* \* `$pullAll` (>= 4.12.0)
* - `$set`
* - `$unset`
* - `$push` (>= 4.8.0)
* - `$addToSet` (>= 4.8.0)
* - `$pull` (>= 4.12.0)
* - `$pullAll` (>= 4.12.0)
*
* For instance, the below update will succeed, regardless of the value of
* `number`, because update validators ignore `$inc`. Also, `$push`,
Expand Down

0 comments on commit d7232de

Please sign in to comment.