From c31e5f331684e95f53b29f4586378cb4e5680256 Mon Sep 17 00:00:00 2001 From: Gregor Yushinov Date: Fri, 13 Oct 2017 03:13:21 +0200 Subject: [PATCH 1/3] Added eachAsync options for concurrency --- types/mongoose/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index cd7bb438d4..602b700958 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -469,6 +469,11 @@ declare module "mongoose" { static Messages: Object; } + interface EachAsyncOptions { + /** defaults to 1 */ + parallel?: number; + } + /* * section querycursor.js * http://mongoosejs.com/docs/api.html#querycursor-js @@ -502,7 +507,7 @@ declare module "mongoose" { * Returns a promise that resolves when done. * @param callback executed when all docs have been processed */ - eachAsync(fn: (doc: T) => any, callback?: (err: any) => void): Promise; + eachAsync(fn: (doc: T) => any, options: EachAsyncOptions, callback?: (err: any) => void): Promise; /** * Registers a transform function which subsequently maps documents retrieved From e08d727565ea52385bb3d860e69b3ac2dc7e1728 Mon Sep 17 00:00:00 2001 From: Gregor Yushinov Date: Thu, 19 Oct 2017 15:33:20 +0200 Subject: [PATCH 2/3] Added overload function definition for eachAsync --- types/mongoose/index.d.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 602b700958..3e1002fd3c 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -505,7 +505,18 @@ declare module "mongoose" { * Execute fn for every document in the cursor. If fn returns a promise, * will wait for the promise to resolve before iterating on to the next one. * Returns a promise that resolves when done. - * @param callback executed when all docs have been processed + * @param fn Function to be executed for every document in the cursor + * @param callback Executed when all docs have been processed + */ + eachAsync(fn: (doc: T) => any, callback?: (err: any) => void): Promise; + + /** + * Execute fn for every document in the cursor. If fn returns a promise, + * will wait for the promise to resolve before iterating on to the next one. + * Returns a promise that resolves when done. + * @param fn Function to be executed for every document in the cursor + * @param options Async options (e. g. parallel function execution) + * @param callback Executed when all docs have been processed */ eachAsync(fn: (doc: T) => any, options: EachAsyncOptions, callback?: (err: any) => void): Promise; From 01be23749e8cfd546b1a68b0e4edf501a254cddc Mon Sep 17 00:00:00 2001 From: Gregor Yushinov Date: Sun, 5 Nov 2017 02:49:22 +0100 Subject: [PATCH 3/3] One can set connection options on the object's root level now All options which usually have been passed in the db/auth/server/replset object can now be set directly in the connection options. If you don't do so you get hints in the debug console. For reference see: https://github.com/Automattic/mongoose/blob/master/lib/drivers/node-mongodb-native/connection.js#L272 --- types/mongoose/index.d.ts | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 261b8ade84..7e45ea835a 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -364,6 +364,49 @@ declare module "mongoose" { pass?: string; /** options for authentication (see http://mongodb.github.com/node-mongodb-native/api-generated/db.html#authenticate) */ auth?: any; + /** Use ssl connection (needs to have a mongod server with ssl support) (default: true) */ + ssl?: boolean; + /** Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. */ + sslValidate?: object; + /** Reconnect on error (default: true) */ + poolSize?: number; + /** Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher) */ + autoReconnect?: boolean; + /** TCP KeepAlive on the socket with a X ms delay before start (default: 0). */ + keepAlive?: number; + /** TCP Connection timeout setting (default: 0) */ + connectTimeoutMS?: number; + /** TCP Socket timeout setting (default: 0) */ + socketTimeoutMS?: number; + /** If the database authentication is dependent on another databaseName. */ + authSource?: string; + /** Attempt to reconnect #times (default: 30) */ + retries?: number; + /** Will wait # milliseconds between retries (default: 1000) */ + reconnectWait?: number; + /** The name of the replicaset to connect to. */ + replicaSet?: string; + /** The current value of the parameter native_parser */ + nativeParser?: boolean; + /** Auth mechanism */ + authMechanism?: any; + /** Specify a journal write concern (default: false). */ + journal?: boolean; + /** The write concern */ + w?: number|string; + /** The write concern timeout. */ + wTimeoutMS?: number; + /** The ReadPreference mode as listed here: http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html */ + readPreference?: string; + /** An object representing read preference tags, see: http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html */ + readPreferencetags?: object; + + // TODO + safe?: any; + fsync?: any; + rs_name?: any; + slaveOk?: any; + authdb?: any; } /** See the node-mongodb-native driver instance for options that it understands. */