[@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
This commit is contained in:
dinodeSimon
2019-08-30 11:04:35 +10:00
committed by Ron Buckton
parent 25cf01cfd3
commit 0d45a2d5af
2 changed files with 8 additions and 1 deletions

View File

@@ -28,6 +28,7 @@
// Richard Davison <https://github.com/richarddd>
// Brian Chen <https://github.com/ToucheSir>
// Boris Figovsky <https://github.com/borfig>
// Simon Driscoll <https://github.com/dinodeSimon>
// 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;

View File

@@ -28,7 +28,8 @@ const connection2: Promise<mongoose.Mongoose> = mongoose.connect(connectUri, {
useNewUrlParser: true,
useFindAndModify: true,
useCreateIndex: true,
autoIndex: true
autoIndex: true,
autoCreate: true,
});
const connection3 = mongoose.connect(connectUri, function (error) {
error.stack;