Skip to content

Commit

Permalink
Merge pull request #12686 from Automattic/vkarpov15/gh-12599
Browse files Browse the repository at this point in the history
docs: fix inverted explanation of `justOne` option for populate
  • Loading branch information
hasezoey authored Nov 21, 2022
2 parents 4324a04 + a5d2acf commit 15c0068
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -4556,7 +4556,7 @@ Model.validate = function validate(obj, pathsToValidate, context, callback) {
* - match: optional query conditions to match
* - model: optional name of the model to use for population
* - options: optional query options like sort, limit, etc
* - justOne: optional boolean, if true Mongoose will always set `path` to an array. Inferred from schema by default.
* - justOne: optional boolean, if true Mongoose will always set `path` to a document, or `null` if no document was found. If false, Mongoose will always set `path` to an array, which will be empty if no documents are found. Inferred from schema by default.
* - strictPopulate: optional boolean, set to `false` to allow populating paths that aren't in the schema.
*
* #### Example:
Expand Down
5 changes: 3 additions & 2 deletions types/populate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ declare module 'mongoose' {
/** deep populate */
populate?: string | PopulateOptions | (string | PopulateOptions)[];
/**
* If true Mongoose will always set `path` to an array, if false Mongoose will
* always set `path` to a document. Inferred from schema by default.
* If true Mongoose will always set `path` to a document, or `null` if no document was found.
* If false Mongoose will always set `path` to an array, which will be empty if no documents are found.
* Inferred from schema by default.
*/
justOne?: boolean;
/** transform function to call on every populated doc */
Expand Down

0 comments on commit 15c0068

Please sign in to comment.