From aa6fe26cea49ca64d81c8681eb83c24f39948fb7 Mon Sep 17 00:00:00 2001 From: Heath Date: Wed, 3 Oct 2018 14:46:53 -0400 Subject: [PATCH] @types/mongoose add missing options to connect() (#29398) @types/mongoose add missing options to connect() --- types/mongoose/index.d.ts | 19 +++++++++++++------ types/mongoose/mongoose-tests.ts | 6 ++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 7a28f641f6..a296234559 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -387,6 +387,8 @@ declare module "mongoose" { /** Flag for using new URL string parser instead of current (deprecated) one */ useNewUrlParser?: boolean; + /** Set to false to make findOneAndUpdate() and findOneAndRemove() use native findOneAndUpdate() rather than findAndModify(). */ + useFindAndModify?: boolean; // TODO safe?: any; @@ -405,6 +407,11 @@ declare module "mongoose" { * models associated with this connection. */ autoIndex?: boolean; + + /** + * If true, this connection will use createIndex() instead of ensureIndex() for automatic index builds via Model.init(). + */ + useCreateIndex?: boolean; }; } @@ -2832,7 +2839,7 @@ declare module "mongoose" { /** sets the document fields to return */ select?: any; }, callback?: (err: any, res: T | null) => void): DocumentQuery; - + /** * Issues a mongodb findOneAndDelete command. * Finds a matching document, removes it, passing the found document (if any) to the @@ -2850,13 +2857,13 @@ declare module "mongoose" { /** puts a time limit on the query - requires mongodb >= 2.6.0 */ maxTimeMS?: number; /** sets the document fields to return */ - select?: any; - /** like select, it determines which fields to return */ + select?: any; + /** like select, it determines which fields to return */ projection?: any; - /** if true, returns the raw result from the MongoDB driver */ + /** if true, returns the raw result from the MongoDB driver */ rawResult?: boolean; - /** overwrites the schema's strict mode option for this update */ - strict?: boolean|string; + /** overwrites the schema's strict mode option for this update */ + strict?: boolean|string; }, callback?: (err: any, res: T | null) => void): DocumentQuery; /** diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index d8f55f6f97..20b24ba887 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -21,11 +21,13 @@ const connection2: Promise = mongoose.connect(connectUri, { user: 'larry', pass: 'housan', config: { - autoIndex: true + autoIndex: true, + useCreateIndex: true, }, mongos: true, bufferCommands: false, - useNewUrlParser: true + useNewUrlParser: true, + useFindAndModify: true, }); const connection3: null = mongoose.connect(connectUri, function (error) { error.stack;