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;