mongoose 6.5.4 → 6.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/aggregate.js CHANGED
@@ -43,7 +43,7 @@ const validRedactStringValues = new Set(['$$DESCEND', '$$PRUNE', '$$KEEP']);
43
43
  * new Aggregate([{ $match: { _id: new mongoose.Types.ObjectId('00000000000000000000000a') } }]);
44
44
  *
45
45
  * @see MongoDB https://docs.mongodb.org/manual/applications/aggregation/
46
- * @see driver https://mongodb.github.com/node-mongodb-native/api-generated/collection.html#aggregate
46
+ * @see driver https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#aggregate
47
47
  * @param {Array} [pipeline] aggregation pipeline as an array of objects
48
48
  * @param {Model} [model] the model to use with this aggregate.
49
49
  * @api public
@@ -623,7 +623,6 @@ Aggregate.prototype.unionWith = function(options) {
623
623
  * @return {Aggregate} this
624
624
  * @api public
625
625
  * @see mongodb https://docs.mongodb.org/manual/applications/replication/#read-preference
626
- * @see driver https://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences
627
626
  */
628
627
 
629
628
  Aggregate.prototype.read = function(pref, tags) {
@@ -766,7 +765,7 @@ Aggregate.prototype.explain = function(verbosity, callback) {
766
765
  };
767
766
 
768
767
  /**
769
- * Sets the allowDiskUse option for the aggregation query (ignored for < 2.6.0)
768
+ * Sets the allowDiskUse option for the aggregation query
770
769
  *
771
770
  * #### Example:
772
771
  *
@@ -783,7 +782,7 @@ Aggregate.prototype.allowDiskUse = function(value) {
783
782
  };
784
783
 
785
784
  /**
786
- * Sets the hint option for the aggregation query (ignored for < 3.6.0)
785
+ * Sets the hint option for the aggregation query
787
786
  *
788
787
  * #### Example:
789
788
  *
@@ -863,7 +862,7 @@ Aggregate.prototype.option = function(value) {
863
862
  * @param {Boolean} [options.useMongooseAggCursor] use experimental mongoose-specific aggregation cursor (for `eachAsync()` and other query cursor semantics)
864
863
  * @return {AggregationCursor} cursor representing this aggregation
865
864
  * @api public
866
- * @see mongodb https://mongodb.github.io/node-mongodb-native/2.0/api/AggregationCursor.html
865
+ * @see mongodb https://mongodb.github.io/node-mongodb-native/4.9/classes/AggregationCursor.html
867
866
  */
868
867
 
869
868
  Aggregate.prototype.cursor = function(options) {
@@ -881,7 +880,7 @@ Aggregate.prototype.cursor = function(options) {
881
880
  * @param {Object} collation options
882
881
  * @return {Aggregate} this
883
882
  * @api public
884
- * @see mongodb https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#aggregate
883
+ * @see mongodb https://mongodb.github.io/node-mongodb-native/4.9/interfaces/CollationOptions.html
885
884
  */
886
885
 
887
886
  Aggregate.prototype.collation = function(collation) {
package/lib/connection.js CHANGED
@@ -387,11 +387,11 @@ Connection.prototype.config;
387
387
  * with specified options. Used to create [capped collections](https://docs.mongodb.com/manual/core/capped-collections/)
388
388
  * and [views](https://docs.mongodb.com/manual/core/views/) from mongoose.
389
389
  *
390
- * Options are passed down without modification to the [MongoDB driver's `createCollection()` function](https://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createCollection)
390
+ * Options are passed down without modification to the [MongoDB driver's `createCollection()` function](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#createCollection)
391
391
  *
392
392
  * @method createCollection
393
393
  * @param {string} collection The collection to create
394
- * @param {Object} [options] see [MongoDB driver docs](https://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createCollection)
394
+ * @param {Object} [options] see [MongoDB driver docs](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#createCollection)
395
395
  * @param {Function} [callback]
396
396
  * @return {Promise} Returns a Promise if no `callback` is given.
397
397
  * @api public
@@ -423,7 +423,7 @@ Connection.prototype.createCollection = _wrapConnHelper(function createCollectio
423
423
  *
424
424
  *
425
425
  * @method startSession
426
- * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#startSession)
426
+ * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession)
427
427
  * @param {Boolean} [options.causalConsistency=true] set to false to disable causal consistency
428
428
  * @param {Function} [callback]
429
429
  * @return {Promise<ClientSession>} promise that resolves to a MongoDB driver `ClientSession`
@@ -445,7 +445,7 @@ Connection.prototype.startSession = _wrapConnHelper(function startSession(option
445
445
  * async function executes successfully and attempt to retry if
446
446
  * there was a retriable error.
447
447
  *
448
- * Calls the MongoDB driver's [`session.withTransaction()`](https://mongodb.github.io/node-mongodb-native/3.5/api/ClientSession.html#withTransaction),
448
+ * Calls the MongoDB driver's [`session.withTransaction()`](https://mongodb.github.io/node-mongodb-native/4.9/classes/ClientSession.html#withTransaction),
449
449
  * but also handles resetting Mongoose document state as shown below.
450
450
  *
451
451
  * #### Example:
@@ -656,7 +656,7 @@ Connection.prototype.onOpen = function() {
656
656
  * Opens the connection with a URI using `MongoClient.connect()`.
657
657
  *
658
658
  * @param {String} uri The URI to connect with.
659
- * @param {Object} [options] Passed on to https://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#connect
659
+ * @param {Object} [options] Passed on to [`MongoClient.connect`](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#connect-1)
660
660
  * @param {Boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
661
661
  * @param {Number} [options.bufferTimeoutMS=10000] Mongoose specific option. If `bufferCommands` is true, Mongoose will throw an error after `bufferTimeoutMS` if the operation is still buffered.
662
662
  * @param {String} [options.dbName] The name of the database we want to use. If not provided, use database name from connection string.
@@ -667,7 +667,7 @@ Connection.prototype.onOpen = function() {
667
667
  * @param {Number} [options.serverSelectionTimeoutMS] If `useUnifiedTopology = true`, the MongoDB driver will try to find a server to send any given operation to, and keep retrying for `serverSelectionTimeoutMS` milliseconds before erroring out. If not set, the MongoDB driver defaults to using `30000` (30 seconds).
668
668
  * @param {Number} [options.heartbeatFrequencyMS] If `useUnifiedTopology = true`, the MongoDB driver sends a heartbeat every `heartbeatFrequencyMS` to check on the status of the connection. A heartbeat is subject to `serverSelectionTimeoutMS`, so the MongoDB driver will retry failed heartbeats for up to 30 seconds by default. Mongoose only emits a `'disconnected'` event after a heartbeat has failed, so you may want to decrease this setting to reduce the time between when your server goes down and when Mongoose emits `'disconnected'`. We recommend you do **not** set this setting below 1000, too many heartbeats can lead to performance degradation.
669
669
  * @param {Boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
670
- * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html).
670
+ * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html#promiseLibrary).
671
671
  * @param {Number} [options.connectTimeoutMS=30000] How long the MongoDB driver will wait before killing a socket due to inactivity _during initial connection_. Defaults to 30000. This option is passed transparently to [Node.js' `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback).
672
672
  * @param {Number} [options.socketTimeoutMS=30000] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. A socket may be inactive because of either no activity or a long-running operation. This is set to `30000` by default, you should set this to 2-3x your longest running operation if you expect some of your database operations to run longer than 20 seconds. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
673
673
  * @param {Number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
@@ -1332,7 +1332,7 @@ Connection.prototype.deleteModel = function(name) {
1332
1332
  *
1333
1333
  * @api public
1334
1334
  * @param {Array} [pipeline]
1335
- * @param {Object} [options] passed without changes to [the MongoDB driver's `Db#watch()` function](https://mongodb.github.io/node-mongodb-native/3.4/api/Db.html#watch)
1335
+ * @param {Object} [options] passed without changes to [the MongoDB driver's `Db#watch()` function](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#watch)
1336
1336
  * @return {ChangeStream} mongoose-specific change stream wrapper, inherits from EventEmitter
1337
1337
  */
1338
1338
 
@@ -1434,7 +1434,7 @@ Connection.prototype.optionsProvideAuthenticationData = function(options) {
1434
1434
  };
1435
1435
 
1436
1436
  /**
1437
- * Returns the [MongoDB driver `MongoClient`](https://mongodb.github.io/node-mongodb-native/3.5/api/MongoClient.html) instance
1437
+ * Returns the [MongoDB driver `MongoClient`](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html) instance
1438
1438
  * that this connection uses to talk to MongoDB.
1439
1439
  *
1440
1440
  * #### Example:
@@ -1453,7 +1453,7 @@ Connection.prototype.getClient = function getClient() {
1453
1453
  };
1454
1454
 
1455
1455
  /**
1456
- * Set the [MongoDB driver `MongoClient`](https://mongodb.github.io/node-mongodb-native/3.5/api/MongoClient.html) instance
1456
+ * Set the [MongoDB driver `MongoClient`](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html) instance
1457
1457
  * that this connection uses to talk to MongoDB. This is useful if you already have a MongoClient instance, and want to
1458
1458
  * reuse it.
1459
1459
  *
@@ -173,7 +173,7 @@ AggregationCursor.prototype._markError = function(error) {
173
173
  * @api public
174
174
  * @method close
175
175
  * @emits close
176
- * @see MongoDB driver cursor#close https://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close
176
+ * @see AggregationCursor.close https://mongodb.github.io/node-mongodb-native/4.9/classes/AggregationCursor.html#close
177
177
  */
178
178
 
179
179
  AggregationCursor.prototype.close = function(callback) {
@@ -301,7 +301,7 @@ function _transformForAsyncIterator(doc) {
301
301
  }
302
302
 
303
303
  /**
304
- * Adds a [cursor flag](https://mongodb.github.io/node-mongodb-native/2.2/api/Cursor.html#addCursorFlag).
304
+ * Adds a [cursor flag](https://mongodb.github.io/node-mongodb-native/4.9/classes/AggregationCursor.html#addCursorFlag).
305
305
  * Useful for setting the `noCursorTimeout` and `tailable` flags.
306
306
  *
307
307
  * @param {String} flag
@@ -178,7 +178,7 @@ QueryCursor.prototype._markError = function(error) {
178
178
  * @api public
179
179
  * @method close
180
180
  * @emits close
181
- * @see MongoDB driver cursor#close https://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close
181
+ * @see AggregationCursor.close https://mongodb.github.io/node-mongodb-native/4.9/classes/AggregationCursor.html#close
182
182
  */
183
183
 
184
184
  QueryCursor.prototype.close = function(callback) {
@@ -263,7 +263,7 @@ QueryCursor.prototype.eachAsync = function(fn, opts, callback) {
263
263
  QueryCursor.prototype.options;
264
264
 
265
265
  /**
266
- * Adds a [cursor flag](https://mongodb.github.io/node-mongodb-native/2.2/api/Cursor.html#addCursorFlag).
266
+ * Adds a [cursor flag](https://mongodb.github.io/node-mongodb-native/4.9/classes/FindCursor.html#addCursorFlag).
267
267
  * Useful for setting the `noCursorTimeout` and `tailable` flags.
268
268
  *
269
269
  * @param {String} flag
package/lib/document.js CHANGED
@@ -3681,7 +3681,7 @@ Document.prototype.$toObject = function(options, json) {
3681
3681
  /**
3682
3682
  * Converts this document into a plain-old JavaScript object ([POJO](https://masteringjs.io/tutorials/fundamentals/pojo)).
3683
3683
  *
3684
- * Buffers are converted to instances of [mongodb.Binary](https://mongodb.github.com/node-mongodb-native/api-bson-generated/binary.html) for proper storage.
3684
+ * Buffers are converted to instances of [mongodb.Binary](https://mongodb.github.io/node-mongodb-native/4.9/classes/Binary.html) for proper storage.
3685
3685
  *
3686
3686
  * #### Getters/Virtuals
3687
3687
  *
@@ -3808,7 +3808,7 @@ Document.prototype.$toObject = function(options, json) {
3808
3808
  * @param {Boolean} [options.flattenMaps=false] if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`.
3809
3809
  * @param {Boolean} [options.useProjection=false] - If true, omits fields that are excluded in this document's projection. Unless you specified a projection, this will omit any field that has `select: false` in the schema.
3810
3810
  * @return {Object} js object (not a POJO)
3811
- * @see mongodb.Binary https://mongodb.github.com/node-mongodb-native/api-bson-generated/binary.html
3811
+ * @see mongodb.Binary https://mongodb.github.io/node-mongodb-native/4.9/classes/Binary.html
3812
3812
  * @api public
3813
3813
  * @memberOf Document
3814
3814
  * @instance
@@ -6,13 +6,13 @@ const utils = require('../../utils');
6
6
  * Given a Mongoose index definition (key + options objects) and a MongoDB server
7
7
  * index definition, determine if the two indexes are equal.
8
8
  *
9
- * @param {Object} key the Mongoose index spec
9
+ * @param {Object} schemaIndexKeysObject the Mongoose index spec
10
10
  * @param {Object} options the Mongoose index definition's options
11
11
  * @param {Object} dbIndex the index in MongoDB as returned by `listIndexes()`
12
12
  * @api private
13
13
  */
14
14
 
15
- module.exports = function isIndexEqual(key, options, dbIndex) {
15
+ module.exports = function isIndexEqual(schemaIndexKeysObject, options, dbIndex) {
16
16
  // Special case: text indexes have a special format in the db. For example,
17
17
  // `{ name: 'text' }` becomes:
18
18
  // {
@@ -30,11 +30,11 @@ module.exports = function isIndexEqual(key, options, dbIndex) {
30
30
  delete dbIndex.key._fts;
31
31
  delete dbIndex.key._ftsx;
32
32
  const weights = { ...dbIndex.weights, ...dbIndex.key };
33
- if (Object.keys(weights).length !== Object.keys(key).length) {
33
+ if (Object.keys(weights).length !== Object.keys(schemaIndexKeysObject).length) {
34
34
  return false;
35
35
  }
36
36
  for (const prop of Object.keys(weights)) {
37
- if (!(prop in key)) {
37
+ if (!(prop in schemaIndexKeysObject)) {
38
38
  return false;
39
39
  }
40
40
  const weight = weights[prop];
@@ -78,7 +78,7 @@ module.exports = function isIndexEqual(key, options, dbIndex) {
78
78
  }
79
79
  }
80
80
 
81
- const schemaIndexKeys = Object.keys(key);
81
+ const schemaIndexKeys = Object.keys(schemaIndexKeysObject);
82
82
  const dbIndexKeys = Object.keys(dbIndex.key);
83
83
  if (schemaIndexKeys.length !== dbIndexKeys.length) {
84
84
  return false;
@@ -87,7 +87,7 @@ module.exports = function isIndexEqual(key, options, dbIndex) {
87
87
  if (schemaIndexKeys[i] !== dbIndexKeys[i]) {
88
88
  return false;
89
89
  }
90
- if (!utils.deepEqual(key[schemaIndexKeys[i]], dbIndex.key[dbIndexKeys[i]])) {
90
+ if (!utils.deepEqual(schemaIndexKeysObject[schemaIndexKeys[i]], dbIndex.key[dbIndexKeys[i]])) {
91
91
  return false;
92
92
  }
93
93
  }
@@ -22,6 +22,12 @@ applyHooks.middlewareFunctions = [
22
22
  'init'
23
23
  ];
24
24
 
25
+ /*!
26
+ * ignore
27
+ */
28
+
29
+ const alreadyHookedFunctions = new Set(applyHooks.middlewareFunctions.flatMap(fn => ([fn, `$__${fn}`])));
30
+
25
31
  /**
26
32
  * Register hooks for this model
27
33
  *
@@ -117,6 +123,9 @@ function applyHooks(model, schema, options) {
117
123
  checkForPromise: true
118
124
  });
119
125
  for (const method of customMethods) {
126
+ if (alreadyHookedFunctions.has(method)) {
127
+ continue;
128
+ }
120
129
  if (!middleware.hasHooks(method)) {
121
130
  // Don't wrap if there are no hooks for the custom method to avoid
122
131
  // surprises. Also, `createWrapper()` enforces consistent async,
@@ -30,6 +30,15 @@ module.exports = function applyMethods(model, schema) {
30
30
  throw new Error('You have a method and a property in your schema both ' +
31
31
  'named "' + method + '"');
32
32
  }
33
+
34
+ // Avoid making custom methods if user sets a method to itself, e.g.
35
+ // `schema.method(save, Document.prototype.save)`. Can happen when
36
+ // calling `loadClass()` with a class that `extends Document`. See gh-12254
37
+ if (typeof fn === 'function' && model.prototype[method] === fn) {
38
+ delete schema.methods[method];
39
+ continue;
40
+ }
41
+
33
42
  if (schema.reserved[method] &&
34
43
  !get(schema, `methodOptions.${method}.suppressWarning`, false)) {
35
44
  utils.warn(`mongoose: the method name "${method}" is used by mongoose ` +
@@ -105,6 +105,8 @@ function isModified(modified, path) {
105
105
  if (modified[path]) {
106
106
  return true;
107
107
  }
108
+
109
+ // Is any parent path of `path` modified?
108
110
  const sp = path.split('.');
109
111
  let cur = sp[0];
110
112
  for (let i = 1; i < sp.length; ++i) {
@@ -113,5 +115,18 @@ function isModified(modified, path) {
113
115
  }
114
116
  cur += '.' + sp[i];
115
117
  }
118
+
119
+ // Is any child of `path` modified?
120
+ const modifiedKeys = Object.keys(modified);
121
+ if (modifiedKeys.length) {
122
+ const parentPath = path + '.';
123
+
124
+ for (const modifiedPath of modifiedKeys) {
125
+ if (modifiedPath.slice(0, path.length + 1) === parentPath) {
126
+ return true;
127
+ }
128
+ }
129
+ }
130
+
116
131
  return false;
117
132
  }
package/lib/index.js CHANGED
@@ -293,20 +293,20 @@ Mongoose.prototype.get = Mongoose.prototype.set;
293
293
  * db = mongoose.createConnection();
294
294
  * db.openUri('localhost', 'database', port, [opts]);
295
295
  *
296
- * @param {String} [uri] a mongodb:// URI
297
- * @param {Object} [options] passed down to the [MongoDB driver's `connect()` function](https://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html), except for 4 mongoose-specific options explained below.
296
+ * @param {String} uri mongodb URI to connect to
297
+ * @param {Object} [options] passed down to the [MongoDB driver's `connect()` function](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html), except for 4 mongoose-specific options explained below.
298
298
  * @param {Boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
299
299
  * @param {String} [options.dbName] The name of the database you want to use. If not provided, Mongoose uses the database name from connection string.
300
300
  * @param {String} [options.user] username for authentication, equivalent to `options.auth.user`. Maintained for backwards compatibility.
301
301
  * @param {String} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
302
302
  * @param {Boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
303
- * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html).
303
+ * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html#promiseLibrary).
304
304
  * @param {Number} [options.maxPoolSize=5] The maximum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
305
305
  * @param {Number} [options.minPoolSize=1] The minimum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
306
306
  * @param {Number} [options.connectTimeoutMS=30000] How long the MongoDB driver will wait before killing a socket due to inactivity _during initial connection_. Defaults to 30000. This option is passed transparently to [Node.js' `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback).
307
307
  * @param {Number} [options.socketTimeoutMS=30000] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. A socket may be inactive because of either no activity or a long-running operation. This is set to `30000` by default, you should set this to 2-3x your longest running operation if you expect some of your database operations to run longer than 20 seconds. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
308
308
  * @param {Number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0`, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
309
- * @return {Connection} the created Connection object. Connections are not thenable, so you can't do `await mongoose.createConnection()`. To await use mongoose.createConnection(uri).asPromise() instead.
309
+ * @return {Connection} the created Connection object. Connections are not thenable, so you can't do `await mongoose.createConnection()`. To await use `mongoose.createConnection(uri).asPromise()` instead.
310
310
  * @api public
311
311
  */
312
312
 
@@ -349,8 +349,8 @@ Mongoose.prototype.createConnection = function(uri, options, callback) {
349
349
  * // if error is truthy, the initial connection failed.
350
350
  * })
351
351
  *
352
- * @param {String} uri(s)
353
- * @param {Object} [options] passed down to the [MongoDB driver's `connect()` function](https://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html), except for 4 mongoose-specific options explained below.
352
+ * @param {String} uri mongodb URI to connect to
353
+ * @param {Object} [options] passed down to the [MongoDB driver's `connect()` function](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html), except for 4 mongoose-specific options explained below.
354
354
  * @param {Boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
355
355
  * @param {Number} [options.bufferTimeoutMS=10000] Mongoose specific option. If `bufferCommands` is true, Mongoose will throw an error after `bufferTimeoutMS` if the operation is still buffered.
356
356
  * @param {String} [options.dbName] The name of the database we want to use. If not provided, use database name from connection string.
@@ -361,7 +361,7 @@ Mongoose.prototype.createConnection = function(uri, options, callback) {
361
361
  * @param {Number} [options.serverSelectionTimeoutMS] If `useUnifiedTopology = true`, the MongoDB driver will try to find a server to send any given operation to, and keep retrying for `serverSelectionTimeoutMS` milliseconds before erroring out. If not set, the MongoDB driver defaults to using `30000` (30 seconds).
362
362
  * @param {Number} [options.heartbeatFrequencyMS] If `useUnifiedTopology = true`, the MongoDB driver sends a heartbeat every `heartbeatFrequencyMS` to check on the status of the connection. A heartbeat is subject to `serverSelectionTimeoutMS`, so the MongoDB driver will retry failed heartbeats for up to 30 seconds by default. Mongoose only emits a `'disconnected'` event after a heartbeat has failed, so you may want to decrease this setting to reduce the time between when your server goes down and when Mongoose emits `'disconnected'`. We recommend you do **not** set this setting below 1000, too many heartbeats can lead to performance degradation.
363
363
  * @param {Boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
364
- * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html).
364
+ * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html#promiseLibrary).
365
365
  * @param {Number} [options.connectTimeoutMS=30000] How long the MongoDB driver will wait before killing a socket due to inactivity _during initial connection_. Defaults to 30000. This option is passed transparently to [Node.js' `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback).
366
366
  * @param {Number} [options.socketTimeoutMS=30000] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. A socket may be inactive because of either no activity or a long-running operation. This is set to `30000` by default, you should set this to 2-3x your longest running operation if you expect some of your database operations to run longer than 20 seconds. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
367
367
  * @param {Number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0`, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
@@ -424,7 +424,7 @@ Mongoose.prototype.disconnect = function(callback) {
424
424
  * Sessions are scoped to a connection, so calling `mongoose.startSession()`
425
425
  * starts a session on the [default mongoose connection](/docs/api.html#mongoose_Mongoose-connection).
426
426
  *
427
- * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#startSession)
427
+ * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession)
428
428
  * @param {Boolean} [options.causalConsistency=true] set to false to disable causal consistency
429
429
  * @param {Function} [callback]
430
430
  * @return {Promise<ClientSession>} promise that resolves to a MongoDB driver `ClientSession`