From 0d45a2d5afec79c41ccdde9a8ee75f9c3df8fbb0 Mon Sep 17 00:00:00 2001 From: dinodeSimon <45355318+dinodeSimon@users.noreply.github.com> Date: Fri, 30 Aug 2019 11:04:35 +1000 Subject: [PATCH] [@types/mongoose] Add missing autoCreate?: boolean to ConnectionOptions type (#37853) * Add autocreate to ConnectionOptions https://mongoosejs.com/docs/guide.html#autoCreate was not included in types for Mongoose * Update mongoose-tests.ts * Update mongoose-tests.ts * Update index.d.ts --- types/mongoose/index.d.ts | 6 ++++++ types/mongoose/mongoose-tests.ts | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 37ac6da104..68d99257a3 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -28,6 +28,7 @@ // Richard Davison // Brian Chen // Boris Figovsky +// Simon Driscoll // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -336,6 +337,11 @@ declare module "mongoose" { }; autoIndex?: boolean; + /** Before Mongoose builds indexes, it calls Model.createCollection() + * to create the underlying collection in MongoDB if autoCreate + * is set to true.(default: false) */ + autoCreate?: boolean; + /** Specify a journal write concern (default: false). */ journal?: boolean; diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 8071e56dd5..1f8b97c2e8 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -28,7 +28,8 @@ const connection2: Promise = mongoose.connect(connectUri, { useNewUrlParser: true, useFindAndModify: true, useCreateIndex: true, - autoIndex: true + autoIndex: true, + autoCreate: true, }); const connection3 = mongoose.connect(connectUri, function (error) { error.stack;