From c35210fe190f385aefd23da48aacb770f47c4356 Mon Sep 17 00:00:00 2001 From: thejavascriptman Date: Sat, 19 Oct 2019 07:38:35 +0900 Subject: [PATCH] add missing field to mongoose document (#39226) --- types/mongoose/index.d.ts | 2 ++ types/mongoose/mongoose-tests.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 9673733113..d3dbc9d6aa 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1421,6 +1421,8 @@ declare module "mongoose" { isNew: boolean; /** The documents schema. */ schema: Schema; + /** Empty object that you can use for storing properties on the document */ + $locals: { [k: string]: any }; } interface MongooseDocumentOptionals { diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index a0b3102b6d..397ef94490 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -732,6 +732,7 @@ mongoose.plugin(AwesomeLoggerPlugin, {modelName: 'Executive', time */ var doc = {}; doc.$isDefault('path').valueOf(); +doc.$locals.field = 'value'; const docDotDepopulate: mongoose.MongooseDocument = doc.depopulate('path'); doc.equals(doc).valueOf(); doc.execPopulate().then(function (arg) {