Skip to content

Commit 15c0068

Browse files
authored
Merge pull request #12686 from Automattic/vkarpov15/gh-12599
docs: fix inverted explanation of `justOne` option for populate
2 parents 4324a04 + a5d2acf commit 15c0068

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4556,7 +4556,7 @@ Model.validate = function validate(obj, pathsToValidate, context, callback) {
45564556
* - match: optional query conditions to match
45574557
* - model: optional name of the model to use for population
45584558
* - options: optional query options like sort, limit, etc
4559-
* - justOne: optional boolean, if true Mongoose will always set `path` to an array. Inferred from schema by default.
4559+
* - 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.
45604560
* - strictPopulate: optional boolean, set to `false` to allow populating paths that aren't in the schema.
45614561
*
45624562
* #### Example:

types/populate.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ declare module 'mongoose' {
2626
/** deep populate */
2727
populate?: string | PopulateOptions | (string | PopulateOptions)[];
2828
/**
29-
* If true Mongoose will always set `path` to an array, if false Mongoose will
30-
* always set `path` to a document. Inferred from schema by default.
29+
* If true Mongoose will always set `path` to a document, or `null` if no document was found.
30+
* If false Mongoose will always set `path` to an array, which will be empty if no documents are found.
31+
* Inferred from schema by default.
3132
*/
3233
justOne?: boolean;
3334
/** transform function to call on every populated doc */

0 commit comments

Comments
 (0)