mongoose 6.4.1 → 6.4.4

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.
Files changed (141) hide show
  1. package/.eslintrc.json +4 -2
  2. package/lib/aggregate.js +3 -2
  3. package/lib/cast/date.js +1 -1
  4. package/lib/cast/decimal128.js +1 -1
  5. package/lib/cast/objectid.js +1 -1
  6. package/lib/cast.js +1 -1
  7. package/lib/connection.js +9 -9
  8. package/lib/cursor/AggregationCursor.js +3 -2
  9. package/lib/cursor/QueryCursor.js +5 -4
  10. package/lib/document.js +48 -16
  11. package/lib/drivers/node-mongodb-native/index.js +1 -1
  12. package/lib/error/index.js +12 -12
  13. package/lib/error/messages.js +2 -2
  14. package/lib/error/parallelValidate.js +1 -1
  15. package/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +1 -1
  16. package/lib/helpers/aggregate/stringifyFunctionOperators.js +1 -1
  17. package/lib/helpers/arrayDepth.js +1 -1
  18. package/lib/helpers/cursor/eachAsync.js +1 -1
  19. package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +1 -1
  20. package/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +1 -1
  21. package/lib/helpers/discriminator/getConstructor.js +1 -1
  22. package/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
  23. package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
  24. package/lib/helpers/document/handleSpreadDoc.js +1 -1
  25. package/lib/helpers/each.js +1 -1
  26. package/lib/helpers/get.js +1 -1
  27. package/lib/helpers/getConstructorName.js +1 -1
  28. package/lib/helpers/getDefaultBulkwriteResult.js +1 -1
  29. package/lib/helpers/indexes/applySchemaCollation.js +1 -1
  30. package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
  31. package/lib/helpers/indexes/isDefaultIdIndex.js +1 -1
  32. package/lib/helpers/indexes/isTextIndex.js +1 -1
  33. package/lib/helpers/isMongooseObject.js +1 -1
  34. package/lib/helpers/isObject.js +1 -1
  35. package/lib/helpers/isPromise.js +1 -1
  36. package/lib/helpers/model/applyHooks.js +1 -1
  37. package/lib/helpers/model/applyStaticHooks.js +1 -1
  38. package/lib/helpers/once.js +1 -1
  39. package/lib/helpers/path/flattenObjectWithDottedPaths.js +1 -1
  40. package/lib/helpers/path/parentPaths.js +1 -1
  41. package/lib/helpers/path/setDottedPath.js +1 -1
  42. package/lib/helpers/pluralize.js +1 -1
  43. package/lib/helpers/populate/SkipPopulateValue.js +1 -1
  44. package/lib/helpers/populate/assignRawDocsToIdStructure.js +1 -1
  45. package/lib/helpers/populate/assignVals.js +1 -1
  46. package/lib/helpers/populate/createPopulateQueryFilter.js +1 -1
  47. package/lib/helpers/populate/getModelsMapForPopulate.js +1 -1
  48. package/lib/helpers/populate/leanPopulateMap.js +1 -1
  49. package/lib/helpers/populate/lookupLocalFields.js +1 -1
  50. package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  51. package/lib/helpers/populate/modelNamesFromRefPath.js +1 -1
  52. package/lib/helpers/populate/removeDeselectedForeignField.js +1 -1
  53. package/lib/helpers/populate/validateRef.js +1 -1
  54. package/lib/helpers/printJestWarning.js +1 -1
  55. package/lib/helpers/processConnectionOptions.js +1 -1
  56. package/lib/helpers/projection/applyProjection.js +1 -1
  57. package/lib/helpers/projection/hasIncludedChildren.js +1 -1
  58. package/lib/helpers/projection/parseProjection.js +1 -1
  59. package/lib/helpers/query/applyGlobalOption.js +1 -1
  60. package/lib/helpers/query/applyQueryMiddleware.js +1 -1
  61. package/lib/helpers/query/cast$expr.js +1 -1
  62. package/lib/helpers/query/castFilterPath.js +1 -1
  63. package/lib/helpers/query/castUpdate.js +4 -4
  64. package/lib/helpers/query/sanitizeFilter.js +1 -1
  65. package/lib/helpers/query/sanitizeProjection.js +1 -1
  66. package/lib/helpers/query/trusted.js +1 -1
  67. package/lib/helpers/query/validOps.js +1 -1
  68. package/lib/helpers/query/wrapThunk.js +1 -1
  69. package/lib/helpers/schema/addAutoId.js +1 -1
  70. package/lib/helpers/schema/applyPlugins.js +1 -1
  71. package/lib/helpers/schema/cleanPositionalOperators.js +1 -1
  72. package/lib/helpers/schema/getKeysInSchemaOrder.js +1 -1
  73. package/lib/helpers/schema/getPath.js +1 -1
  74. package/lib/helpers/schema/handleIdOption.js +1 -1
  75. package/lib/helpers/schema/handleTimestampOption.js +1 -1
  76. package/lib/helpers/specialProperties.js +1 -1
  77. package/lib/helpers/symbols.js +1 -1
  78. package/lib/helpers/timers.js +1 -1
  79. package/lib/helpers/timestamps/setupTimestamps.js +1 -1
  80. package/lib/helpers/topology/allServersUnknown.js +1 -1
  81. package/lib/helpers/topology/isAtlas.js +1 -1
  82. package/lib/helpers/topology/isSSLError.js +1 -1
  83. package/lib/helpers/update/applyTimestampsToChildren.js +1 -1
  84. package/lib/helpers/update/castArrayFilters.js +1 -1
  85. package/lib/helpers/update/moveImmutableProperties.js +1 -1
  86. package/lib/helpers/update/removeUnusedArrayFilters.js +1 -1
  87. package/lib/helpers/update/updatedPathsByArrayFilter.js +1 -1
  88. package/lib/index.js +7 -4
  89. package/lib/model.js +22 -21
  90. package/lib/options/PopulateOptions.js +1 -1
  91. package/lib/options/SchemaArrayOptions.js +3 -3
  92. package/lib/options/SchemaBufferOptions.js +2 -2
  93. package/lib/options/SchemaDateOptions.js +3 -3
  94. package/lib/options/SchemaDocumentArrayOptions.js +3 -3
  95. package/lib/options/SchemaMapOptions.js +2 -2
  96. package/lib/options/SchemaNumberOptions.js +5 -5
  97. package/lib/options/SchemaObjectIdOptions.js +3 -3
  98. package/lib/options/SchemaStringOptions.js +8 -8
  99. package/lib/options/SchemaSubdocumentOptions.js +2 -2
  100. package/lib/options/SchemaTypeOptions.js +15 -15
  101. package/lib/options/VirtualOptions.js +12 -12
  102. package/lib/options/propertyOptions.js +1 -1
  103. package/lib/options/removeOptions.js +1 -1
  104. package/lib/options/saveOptions.js +1 -1
  105. package/lib/plugins/trackTransaction.js +1 -1
  106. package/lib/query.js +74 -71
  107. package/lib/schema/SubdocumentPath.js +10 -6
  108. package/lib/schema/array.js +3 -3
  109. package/lib/schema/boolean.js +5 -5
  110. package/lib/schema/buffer.js +2 -2
  111. package/lib/schema/date.js +2 -2
  112. package/lib/schema/decimal128.js +2 -2
  113. package/lib/schema/documentarray.js +12 -8
  114. package/lib/schema/mixed.js +2 -2
  115. package/lib/schema/number.js +2 -2
  116. package/lib/schema/objectid.js +2 -2
  117. package/lib/schema/string.js +2 -2
  118. package/lib/schema/symbols.js +1 -1
  119. package/lib/schema.js +72 -37
  120. package/lib/schematype.js +9 -10
  121. package/lib/types/DocumentArray/methods/index.js +2 -2
  122. package/lib/types/buffer.js +30 -28
  123. package/lib/types/decimal128.js +4 -4
  124. package/lib/types/map.js +70 -0
  125. package/lib/types/objectid.js +1 -1
  126. package/lib/types/subdocument.js +1 -1
  127. package/lib/virtualtype.js +5 -5
  128. package/package.json +13 -13
  129. package/types/collection.d.ts +1 -1
  130. package/types/document.d.ts +4 -4
  131. package/types/expressions.d.ts +27 -8
  132. package/types/index.d.ts +2 -1
  133. package/types/indexes.d.ts +2 -2
  134. package/types/inferschematype.d.ts +51 -33
  135. package/types/middlewares.d.ts +1 -1
  136. package/types/models.d.ts +8 -7
  137. package/types/mongooseoptions.d.ts +1 -1
  138. package/types/pipelinestage.d.ts +1 -1
  139. package/types/query.d.ts +6 -1
  140. package/types/schemaoptions.d.ts +1 -1
  141. package/types/utility.d.ts +7 -0
@@ -68,4 +68,4 @@ module.exports = function applyStaticHooks(model, hooks, statics) {
68
68
  };
69
69
  }
70
70
  }
71
- };
71
+ };
@@ -9,4 +9,4 @@ module.exports = function once(fn) {
9
9
  called = true;
10
10
  return fn.apply(null, arguments);
11
11
  };
12
- };
12
+ };
@@ -35,4 +35,4 @@ module.exports = function flattenObjectWithDottedPaths(obj) {
35
35
 
36
36
  flattenObjectWithDottedPaths(obj[key]);
37
37
  }
38
- };
38
+ };
@@ -15,4 +15,4 @@ module.exports = function parentPaths(path) {
15
15
  }
16
16
 
17
17
  return ret;
18
- };
18
+ };
@@ -30,4 +30,4 @@ module.exports = function setDottedPath(obj, path, val) {
30
30
  if (!specialProperties.has(last)) {
31
31
  cur[last] = val;
32
32
  }
33
- };
33
+ };
@@ -91,4 +91,4 @@ function pluralize(str) {
91
91
  }
92
92
  }
93
93
  return str;
94
- }
94
+ }
@@ -7,4 +7,4 @@ module.exports = function SkipPopulateValue(val) {
7
7
 
8
8
  this.val = val;
9
9
  return this;
10
- };
10
+ };
@@ -106,4 +106,4 @@ function assignRawDocsToIdStructure(rawIds, resultDocs, resultOrder, options, re
106
106
  rawIds[i] = doc;
107
107
  });
108
108
  }
109
- }
109
+ }
@@ -320,4 +320,4 @@ function isPopulatedObject(obj) {
320
320
 
321
321
  function noop(v) {
322
322
  return v;
323
- }
323
+ }
@@ -77,4 +77,4 @@ function _formatMatch(match) {
77
77
  return Object.assign({}, match[0]);
78
78
  }
79
79
  return Object.assign({}, match);
80
- }
80
+ }
@@ -726,4 +726,4 @@ function _findRefPathForDiscriminators(doc, modelSchema, data, options, normaliz
726
726
  }
727
727
 
728
728
  return modelNames;
729
- }
729
+ }
@@ -4,4 +4,4 @@
4
4
  * ignore
5
5
  */
6
6
 
7
- module.exports = new WeakMap();
7
+ module.exports = new WeakMap();
@@ -37,4 +37,4 @@ module.exports = function lookupLocalFields(cur, path, val) {
37
37
  }
38
38
 
39
39
  return cur[path];
40
- };
40
+ };
@@ -39,4 +39,4 @@ module.exports = function markArraySubdocsPopulated(doc, populated) {
39
39
  }
40
40
  }
41
41
  }
42
- };
42
+ };
@@ -65,4 +65,4 @@ module.exports = function modelNamesFromRefPath(refPath, doc, populatedPath, mod
65
65
  modelNames = utils.array.flatten(modelNames);
66
66
 
67
67
  return modelNames;
68
- };
68
+ };
@@ -28,4 +28,4 @@ module.exports = function removeDeselectedForeignField(foreignFields, options, d
28
28
  }
29
29
  }
30
30
  }
31
- };
31
+ };
@@ -16,4 +16,4 @@ function validateRef(ref, path) {
16
16
 
17
17
  throw new MongooseError('Invalid ref at path "' + path + '". Got ' +
18
18
  util.inspect(ref, { depth: 0 }));
19
- }
19
+ }
@@ -14,4 +14,4 @@ if (typeof jest !== 'undefined' && process.nextTick.toString().indexOf('nextTick
14
14
  'with Jest\'s mock timers enabled. Please make sure you read ' +
15
15
  'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +
16
16
  'https://mongoosejs.com/docs/jest.html');
17
- }
17
+ }
@@ -9,7 +9,7 @@ function processConnectionOptions(uri, options) {
9
9
  ? opts.readPreference
10
10
  : getUriReadPreference(uri);
11
11
 
12
- const resolvedOpts = (readPreference && readPreference !== 'primary')
12
+ const resolvedOpts = (readPreference && readPreference !== 'primary' && readPreference !== 'primaryPreferred')
13
13
  ? resolveOptsConflicts(readPreference, opts)
14
14
  : opts;
15
15
 
@@ -74,4 +74,4 @@ function applyInclusiveProjection(doc, projection, hasIncludedChildren, projecti
74
74
  }
75
75
  }
76
76
  return ret;
77
- }
77
+ }
@@ -33,4 +33,4 @@ module.exports = function hasIncludedChildren(fields) {
33
33
  }
34
34
 
35
35
  return hasIncludedChildren;
36
- };
36
+ };
@@ -30,4 +30,4 @@ module.exports = function parseProjection(v, retainMinusPaths) {
30
30
  }
31
31
 
32
32
  return ret;
33
- };
33
+ };
@@ -26,4 +26,4 @@ function applyGlobalOption(options, model, optionName) {
26
26
  } else if (utils.hasUserDefinedProperty(model.base.options, optionName)) {
27
27
  options[optionName] = model.base.options[optionName];
28
28
  }
29
- }
29
+ }
@@ -75,4 +75,4 @@ function _getContexts(hook) {
75
75
  ret.document = hook.document;
76
76
  }
77
77
  return ret;
78
- }
78
+ }
@@ -279,4 +279,4 @@ function isLiteral(val) {
279
279
  return val.$literal != null;
280
280
  }
281
281
  return true;
282
- }
282
+ }
@@ -51,4 +51,4 @@ module.exports = function castFilterPath(query, schematype, val) {
51
51
  }
52
52
 
53
53
  return val;
54
- };
54
+ };
@@ -155,12 +155,12 @@ function castPipelineOperator(op, val) {
155
155
  * according to its schema.
156
156
  *
157
157
  * @param {Schema} schema
158
- * @param {Object} obj - part of a query
159
- * @param {String} op - the atomic operator ($pull, $set, etc)
158
+ * @param {Object} obj part of a query
159
+ * @param {String} op the atomic operator ($pull, $set, etc)
160
160
  * @param {Object} options
161
161
  * @param {Boolean|String} [options.strict]
162
162
  * @param {Query} context
163
- * @param {String} pref - path prefix (internal only)
163
+ * @param {String} pref path prefix (internal only)
164
164
  * @return {Bool} true if this path has keys to update
165
165
  * @api private
166
166
  */
@@ -451,7 +451,7 @@ const overwriteOps = {
451
451
  *
452
452
  * @param {SchemaType} schema
453
453
  * @param {Object} val
454
- * @param {String} op - the atomic operator ($pull, $set, etc)
454
+ * @param {String} op the atomic operator ($pull, $set, etc)
455
455
  * @param {String} $conditional
456
456
  * @param {Query} context
457
457
  * @api private
@@ -35,4 +35,4 @@ module.exports = function sanitizeFilter(filter) {
35
35
  }
36
36
 
37
37
  return filter;
38
- };
38
+ };
@@ -11,4 +11,4 @@ module.exports = function sanitizeProjection(projection) {
11
11
  projection[keys[i]] = 1;
12
12
  }
13
13
  }
14
- };
14
+ };
@@ -10,4 +10,4 @@ exports.trusted = function trusted(obj) {
10
10
  }
11
11
  obj[trustedSymbol] = true;
12
12
  return obj;
13
- };
13
+ };
@@ -21,4 +21,4 @@ module.exports = Object.freeze([
21
21
  'findOneAndDelete',
22
22
  'findOneAndRemove',
23
23
  'remove'
24
- ]);
24
+ ]);
@@ -26,4 +26,4 @@ module.exports = function wrapThunk(fn) {
26
26
 
27
27
  fn.call(this, cb);
28
28
  };
29
- };
29
+ };
@@ -4,4 +4,4 @@ module.exports = function addAutoId(schema) {
4
4
  const _obj = { _id: { auto: true } };
5
5
  _obj._id[schema.options.typeKey] = 'ObjectId';
6
6
  schema.add(_obj);
7
- };
7
+ };
@@ -52,4 +52,4 @@ module.exports = function applyPlugins(schema, plugins, options, cacheKey) {
52
52
  applyPlugins(discriminatorSchema, plugins,
53
53
  { skipTopLevel: !applyPluginsToDiscriminators }, cacheKey);
54
54
  }
55
- };
55
+ };
@@ -9,4 +9,4 @@ module.exports = function cleanPositionalOperators(path) {
9
9
  return path.
10
10
  replace(/\.\$(\[[^\]]*\])?(?=\.)/g, '.0').
11
11
  replace(/\.\$(\[[^\]]*\])?$/g, '.0');
12
- };
12
+ };
@@ -25,4 +25,4 @@ module.exports = function getKeysInSchemaOrder(schema, val, path) {
25
25
  }
26
26
 
27
27
  return keys;
28
- };
28
+ };
@@ -34,4 +34,4 @@ module.exports = function getPath(schema, path) {
34
34
  }
35
35
 
36
36
  return schematype;
37
- };
37
+ };
@@ -17,4 +17,4 @@ module.exports = function handleIdOption(schema, options) {
17
17
  }
18
18
 
19
19
  return schema;
20
- };
20
+ };
@@ -21,4 +21,4 @@ function handleTimestampOption(arg, prop) {
21
21
  return prop;
22
22
  }
23
23
  return arg[prop];
24
- }
24
+ }
@@ -1,3 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = new Set(['__proto__', 'constructor', 'prototype']);
3
+ module.exports = new Set(['__proto__', 'constructor', 'prototype']);
@@ -17,4 +17,4 @@ exports.populateModelSymbol = Symbol('mongoose.PopulateOptions#Model');
17
17
  exports.schemaTypeSymbol = Symbol('mongoose#schemaType');
18
18
  exports.sessionNewDocuments = Symbol('mongoose:ClientSession#newDocuments');
19
19
  exports.scopeSymbol = Symbol('mongoose#Document#scope');
20
- exports.validatorErrorSymbol = Symbol('mongoose:validatorError');
20
+ exports.validatorErrorSymbol = Symbol('mongoose:validatorError');
@@ -1,3 +1,3 @@
1
1
  'use strict';
2
2
 
3
- exports.setTimeout = setTimeout;
3
+ exports.setTimeout = setTimeout;
@@ -102,4 +102,4 @@ module.exports = function setupTimestamps(schema, timestamps) {
102
102
  applyTimestampsToChildren(now, this.getUpdate(), this.model.schema);
103
103
  next();
104
104
  }
105
- };
105
+ };
@@ -9,4 +9,4 @@ module.exports = function allServersUnknown(topologyDescription) {
9
9
 
10
10
  const servers = Array.from(topologyDescription.servers.values());
11
11
  return servers.length > 0 && servers.every(server => server.type === 'Unknown');
12
- };
12
+ };
@@ -23,4 +23,4 @@ module.exports = function isAtlas(topologyDescription) {
23
23
  }
24
24
  }
25
25
  return true;
26
- };
26
+ };
@@ -13,4 +13,4 @@ module.exports = function isSSLError(topologyDescription) {
13
13
  const descriptions = Array.from(topologyDescription.servers.values());
14
14
  return descriptions.length > 0 &&
15
15
  descriptions.every(descr => descr.error && descr.error.message.indexOf(nonSSLMessage) !== -1);
16
- };
16
+ };
@@ -186,4 +186,4 @@ function applyTimestampsToUpdateKey(schema, key, update, now) {
186
186
  update[key][createdAt] = now;
187
187
  }
188
188
  }
189
- }
189
+ }
@@ -80,4 +80,4 @@ function _castArrayFilters(arrayFilters, schema, strictQuery, updatedPathsByFilt
80
80
  }
81
81
  }
82
82
  }
83
- }
83
+ }
@@ -50,4 +50,4 @@ function _walkUpdatePath(schema, op, path, update, ctx) {
50
50
  update.$setOnInsert = update.$setOnInsert || {};
51
51
  update.$setOnInsert[path] = op[path];
52
52
  delete op[path];
53
- }
53
+ }
@@ -29,4 +29,4 @@ function _checkSingleFilterKey(arrayFilter, updateKeys) {
29
29
  const arrayFilterKey = firstDot === -1 ? firstKey : firstKey.slice(0, firstDot);
30
30
 
31
31
  return updateKeys.find(key => key.includes('$[' + arrayFilterKey + ']')) != null;
32
- }
32
+ }
@@ -24,4 +24,4 @@ module.exports = function updatedPathsByArrayFilter(update) {
24
24
  }
25
25
  return cur;
26
26
  }, {});
27
- };
27
+ };
package/lib/index.js CHANGED
@@ -172,6 +172,7 @@ Mongoose.prototype.setDriver = function setDriver(driver) {
172
172
 
173
173
  const Connection = driver.getConnection();
174
174
  _mongoose.connections = [new Connection(_mongoose)];
175
+ _mongoose.connections[0].models = _mongoose.models;
175
176
 
176
177
  return _mongoose;
177
178
  };
@@ -761,6 +762,8 @@ Mongoose.prototype.Aggregate = Aggregate;
761
762
  /**
762
763
  * The Mongoose Collection constructor
763
764
  *
765
+ * @memberOf Mongoose
766
+ * @instance
764
767
  * @method Collection
765
768
  * @api public
766
769
  */
@@ -799,7 +802,7 @@ Object.defineProperty(Mongoose.prototype, 'Connection', {
799
802
  /**
800
803
  * The Mongoose version
801
804
  *
802
- * #### Example
805
+ * #### Example:
803
806
  *
804
807
  * console.log(mongoose.version); // '5.x.x'
805
808
  *
@@ -1044,7 +1047,7 @@ Mongoose.prototype.isObjectIdOrHexString = function(v) {
1044
1047
  *
1045
1048
  * @param {Object} options
1046
1049
  * @param {Boolean} options.continueOnError `false` by default. If set to `true`, mongoose will not throw an error if one model syncing failed, and will return an object where the keys are the names of the models, and the values are the results/errors for each model.
1047
- * @returns
1050
+ * @return {Promise} Returns a Promise, when the Promise resolves the value is a list of the dropped indexes.
1048
1051
  */
1049
1052
  Mongoose.prototype.syncIndexes = function(options) {
1050
1053
  const _mongoose = this instanceof Mongoose ? this : mongoose;
@@ -1223,7 +1226,7 @@ Mongoose.prototype._promiseOrCallback = function(callback, fn, ee) {
1223
1226
  /**
1224
1227
  * Use this function in `pre()` middleware to skip calling the wrapped function.
1225
1228
  *
1226
- * ####Example:
1229
+ * #### Example:
1227
1230
  *
1228
1231
  * schema.pre('save', function() {
1229
1232
  * // Will skip executing `save()`, but will execute post hooks as if
@@ -1241,7 +1244,7 @@ Mongoose.prototype.skipMiddlewareFunction = Kareem.skipWrappedFunction;
1241
1244
  /**
1242
1245
  * Use this function in `post()` middleware to replace the result
1243
1246
  *
1244
- * ####Example:
1247
+ * #### Example:
1245
1248
  *
1246
1249
  * schema.post('find', function(res) {
1247
1250
  * // Normally you have to modify `res` in place. But with
package/lib/model.js CHANGED
@@ -212,7 +212,7 @@ Model.prototype.baseModelName;
212
212
  * @api public
213
213
  * @fires error whenever any query or model function errors
214
214
  * @memberOf Model
215
- * @static events
215
+ * @static
216
216
  */
217
217
 
218
218
  Model.events;
@@ -899,6 +899,7 @@ Model.prototype.$__version = function(where, delta) {
899
899
  * })
900
900
  *
901
901
  * @see versionKeys https://mongoosejs.com/docs/guide.html#versionKey
902
+ * @memberOf Model
902
903
  * @api public
903
904
  */
904
905
 
@@ -1453,7 +1454,7 @@ Model.createCollection = function createCollection(options, callback) {
1453
1454
  * @param {Object} [options] options to pass to `ensureIndexes()`
1454
1455
  * @param {Boolean} [options.background=null] if specified, overrides each index's `background` property
1455
1456
  * @param {Function} [callback] optional callback
1456
- * @return {Promise|undefined} Returns `undefined` if callback is specified, returns a promise if no callback.
1457
+ * @return {Promise|undefined} Returns `undefined` if callback is specified, returns a promise if no callback, when the Promise resolves the value is a list of the dropped indexes.
1457
1458
  * @api public
1458
1459
  */
1459
1460
 
@@ -1821,7 +1822,7 @@ function _ensureIndexes(model, options, callback) {
1821
1822
  * Schema the model uses.
1822
1823
  *
1823
1824
  * @property schema
1824
- * @receiver Model
1825
+ * @static
1825
1826
  * @api public
1826
1827
  * @memberOf Model
1827
1828
  */
@@ -2128,7 +2129,7 @@ Model.deleteMany = function deleteMany(conditions, options, callback) {
2128
2129
  * await MyModel.find({ name: /john/i }, null, { skip: 10 }).exec();
2129
2130
  *
2130
2131
  * @param {Object|ObjectId} filter
2131
- * @param {Object|String|Array<String>} [projection] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api.html#query_Query-select)
2132
+ * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api.html#query_Query-select)
2132
2133
  * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
2133
2134
  * @param {Function} [callback]
2134
2135
  * @return {Query}
@@ -2191,7 +2192,7 @@ Model.find = function find(conditions, projection, options, callback) {
2191
2192
  * await Adventure.findById(id, 'name length').exec();
2192
2193
  *
2193
2194
  * @param {Any} id value of `_id` to query by
2194
- * @param {Object|String|Array<String>} [projection] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2195
+ * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2195
2196
  * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
2196
2197
  * @param {Function} [callback]
2197
2198
  * @return {Query}
@@ -2234,7 +2235,7 @@ Model.findById = function findById(id, projection, options, callback) {
2234
2235
  * await Adventure.findOne({ country: 'Croatia' }, 'name length').exec();
2235
2236
  *
2236
2237
  * @param {Object} [conditions]
2237
- * @param {Object|String|Array<String>} [projection] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2238
+ * @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2238
2239
  * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
2239
2240
  * @param {Function} [callback]
2240
2241
  * @return {Query}
@@ -2383,7 +2384,7 @@ Model.count = function count(conditions, callback) {
2383
2384
  *
2384
2385
  * Passing a `callback` executes the query.
2385
2386
  *
2386
- * #### Example
2387
+ * #### Example:
2387
2388
  *
2388
2389
  * Link.distinct('url', { clicks: {$gt: 100}}, function (err, result) {
2389
2390
  * if (err) return handleError(err);
@@ -2532,7 +2533,7 @@ Model.$where = function $where() {
2532
2533
  * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
2533
2534
  * @param {Boolean} [options.overwrite=false] By default, if you don't include any [update operators](https://docs.mongodb.com/manual/reference/operator/update/) in `update`, Mongoose will wrap `update` in `$set` for you. This prevents you from accidentally overwriting the document. This option tells Mongoose to skip adding `$set`. An alternative to this would be using [Model.findOneAndReplace(conditions, update, options, callback)](https://mongoosejs.com/docs/api/model.html#model_Model.findOneAndReplace).
2534
2535
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
2535
- * @param {Object|String|Array<String>} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2536
+ * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2536
2537
  * @param {Function} [callback]
2537
2538
  * @return {Query}
2538
2539
  * @see Tutorial /docs/tutorials/findoneandupdate.html
@@ -2748,7 +2749,7 @@ Model.findByIdAndUpdate = function(id, update, options, callback) {
2748
2749
  * @param {Object} conditions
2749
2750
  * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
2750
2751
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
2751
- * @param {Object|String|Array<String>} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2752
+ * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2752
2753
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
2753
2754
  * @param {Function} [callback]
2754
2755
  * @return {Query}
@@ -2854,7 +2855,7 @@ Model.findByIdAndDelete = function(id, options, callback) {
2854
2855
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
2855
2856
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
2856
2857
  * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
2857
- * @param {Object|String|Array<String>} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2858
+ * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2858
2859
  * @param {Function} [callback]
2859
2860
  * @return {Query}
2860
2861
  * @api public
@@ -2941,7 +2942,7 @@ Model.findOneAndReplace = function(filter, replacement, options, callback) {
2941
2942
  * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
2942
2943
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
2943
2944
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
2944
- * @param {Object|String|Array<String>} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2945
+ * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2945
2946
  * @param {Function} [callback]
2946
2947
  * @return {Query}
2947
2948
  * @see mongodb https://www.mongodb.org/display/DOCS/findAndModify+Command
@@ -3007,7 +3008,7 @@ Model.findOneAndRemove = function(conditions, options, callback) {
3007
3008
  * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
3008
3009
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3009
3010
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3010
- * @param {Object|String|Array<String>} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
3011
+ * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
3011
3012
  * @param {Function} [callback]
3012
3013
  * @return {Query}
3013
3014
  * @see Model.findOneAndRemove #model_Model.findOneAndRemove
@@ -3287,11 +3288,11 @@ Model.startSession = function() {
3287
3288
  *
3288
3289
  * @param {Array|Object|*} doc(s)
3289
3290
  * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany)
3290
- * @param {Boolean} [options.ordered = true] if true, will fail fast on the first error encountered. If false, will insert all the documents it can and report errors later. An `insertMany()` with `ordered = false` is called an "unordered" `insertMany()`.
3291
- * @param {Boolean} [options.rawResult = false] if false, the returned promise resolves to the documents that passed mongoose document validation. If `true`, will return the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~insertWriteOpCallback) with a `mongoose` property that contains `validationErrors` if this is an unordered `insertMany`.
3292
- * @param {Boolean} [options.lean = false] if `true`, skips hydrating and validating the documents. This option is useful if you need the extra performance, but Mongoose won't validate the documents before inserting.
3293
- * @param {Number} [options.limit = null] this limits the number of documents being processed (validation/casting) by mongoose in parallel, this does **NOT** send the documents in batches to MongoDB. Use this option if you're processing a large number of documents and your app is running out of memory.
3294
- * @param {String|Object|Array} [options.populate = null] populates the result documents. This option is a no-op if `rawResult` is set.
3291
+ * @param {Boolean} [options.ordered=true] if true, will fail fast on the first error encountered. If false, will insert all the documents it can and report errors later. An `insertMany()` with `ordered = false` is called an "unordered" `insertMany()`.
3292
+ * @param {Boolean} [options.rawResult=false] if false, the returned promise resolves to the documents that passed mongoose document validation. If `true`, will return the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~insertWriteOpCallback) with a `mongoose` property that contains `validationErrors` if this is an unordered `insertMany`.
3293
+ * @param {Boolean} [options.lean=false] if `true`, skips hydrating and validating the documents. This option is useful if you need the extra performance, but Mongoose won't validate the documents before inserting.
3294
+ * @param {Number} [options.limit=null] this limits the number of documents being processed (validation/casting) by mongoose in parallel, this does **NOT** send the documents in batches to MongoDB. Use this option if you're processing a large number of documents and your app is running out of memory.
3295
+ * @param {String|Object|Array} [options.populate=null] populates the result documents. This option is a no-op if `rawResult` is set.
3295
3296
  * @param {Function} [callback] callback
3296
3297
  * @return {Promise} resolving to the raw result from the MongoDB driver if `options.rawResult` was `true`, or the documents that passed validation, otherwise
3297
3298
  * @api public
@@ -3613,7 +3614,7 @@ Model.bulkWrite = function(ops, options, callback) {
3613
3614
  *
3614
3615
  * `bulkSave` uses `bulkWrite` under the hood, so it's mostly useful when dealing with many documents (10K+)
3615
3616
  *
3616
- * @param {[Document]} documents
3617
+ * @param {Array<Document>} documents
3617
3618
  * @param {Object} [options] options passed to the underlying `bulkWrite()`
3618
3619
  * @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](/docs/transactions.html).
3619
3620
  * @param {String|number} [options.w=1] The [write concern](https://docs.mongodb.com/manual/reference/write-concern/). See [`Query#w()`](/docs/api.html#query_Query-w) for more information.
@@ -3687,10 +3688,10 @@ function handleSuccessfulWrite(document, resolve, reject) {
3687
3688
 
3688
3689
  /**
3689
3690
  *
3690
- * @param {[Document]} documents The array of documents to build write operations of
3691
+ * @param {Array<Document>} documents The array of documents to build write operations of
3691
3692
  * @param {Object} options
3692
3693
  * @param {Boolean} options.skipValidation defaults to `false`, when set to true, building the write operations will bypass validating the documents.
3693
- * @returns
3694
+ * @return {Array<Promise>} Returns a array of all Promises the function executes to be awaited.
3694
3695
  */
3695
3696
  Model.buildBulkWriteOperations = function buildBulkWriteOperations(documents, options) {
3696
3697
  if (!Array.isArray(documents)) {
@@ -3764,7 +3765,7 @@ Model.buildBulkWriteOperations = function buildBulkWriteOperations(documents, op
3764
3765
  * const mongooseCandy = Candy.hydrate({ _id: '54108337212ffb6d459f854c', type: 'jelly bean' });
3765
3766
  *
3766
3767
  * @param {Object} obj
3767
- * @param {Object|String|Array<String>} [projection] optional projection containing which fields should be selected for this document
3768
+ * @param {Object|String|String[]} [projection] optional projection containing which fields should be selected for this document
3768
3769
  * @return {Document} document instance
3769
3770
  * @api public
3770
3771
  */
@@ -33,4 +33,4 @@ class PopulateOptions {
33
33
  * @api public
34
34
  */
35
35
 
36
- module.exports = PopulateOptions;
36
+ module.exports = PopulateOptions;
@@ -26,7 +26,7 @@ const opts = require('./propertyOptions');
26
26
  * @api public
27
27
  * @property enum
28
28
  * @memberOf SchemaArrayOptions
29
- * @type Array
29
+ * @type {Array}
30
30
  * @instance
31
31
  */
32
32
 
@@ -46,7 +46,7 @@ Object.defineProperty(SchemaArrayOptions.prototype, 'enum', opts);
46
46
  * @api public
47
47
  * @property of
48
48
  * @memberOf SchemaArrayOptions
49
- * @type Function|String
49
+ * @type {Function|String}
50
50
  * @instance
51
51
  */
52
52
 
@@ -56,4 +56,4 @@ Object.defineProperty(SchemaArrayOptions.prototype, 'of', opts);
56
56
  * ignore
57
57
  */
58
58
 
59
- module.exports = SchemaArrayOptions;
59
+ module.exports = SchemaArrayOptions;