From ed6740fa2febde83bfd9606512cf81b35205d7d9 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sat, 12 Nov 2022 17:19:11 -0500 Subject: [PATCH] docs: fix inverted explanation of `justOne` option for populate Fix #12599 --- lib/model.js | 2 +- types/populate.d.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/model.js b/lib/model.js index 8f876bc3321..bce27dc970d 100644 --- a/lib/model.js +++ b/lib/model.js @@ -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 false, Mongoose will always set `path` to a potentially empty array. Inferred from schema by default. * - strictPopulate: optional boolean, set to `false` to allow populating paths that aren't in the schema. * * #### Example: diff --git a/types/populate.d.ts b/types/populate.d.ts index 3d53cea140c..f30cd0eccec 100644 --- a/types/populate.d.ts +++ b/types/populate.d.ts @@ -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 false Mongoose will always set `path` to a potentially empty array. + * Inferred from schema by default. */ justOne?: boolean; /** transform function to call on every populated doc */