mongoose 6.2.7 → 6.2.10

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 (59) hide show
  1. package/.eslintrc.json +35 -26
  2. package/CHANGELOG.md +27 -0
  3. package/dist/browser.umd.js +71 -71
  4. package/lib/aggregate.js +36 -36
  5. package/lib/browser.js +4 -4
  6. package/lib/browserDocument.js +1 -0
  7. package/lib/connection.js +21 -21
  8. package/lib/cursor/AggregationCursor.js +2 -3
  9. package/lib/cursor/QueryCursor.js +3 -3
  10. package/lib/document.js +75 -47
  11. package/lib/error/index.js +2 -2
  12. package/lib/helpers/document/handleSpreadDoc.js +19 -1
  13. package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  14. package/lib/helpers/projection/hasIncludedChildren.js +1 -1
  15. package/lib/helpers/query/castFilterPath.js +0 -1
  16. package/lib/index.js +24 -26
  17. package/lib/model.js +141 -136
  18. package/lib/options/SchemaArrayOptions.js +2 -2
  19. package/lib/options/SchemaBufferOptions.js +1 -1
  20. package/lib/options/SchemaDateOptions.js +9 -2
  21. package/lib/options/SchemaDocumentArrayOptions.js +3 -3
  22. package/lib/options/SchemaMapOptions.js +2 -2
  23. package/lib/options/SchemaNumberOptions.js +3 -3
  24. package/lib/options/SchemaObjectIdOptions.js +2 -2
  25. package/lib/options/SchemaStringOptions.js +1 -1
  26. package/lib/options/SchemaSubdocumentOptions.js +2 -2
  27. package/lib/options/SchemaTypeOptions.js +3 -3
  28. package/lib/query.js +253 -225
  29. package/lib/schema/SubdocumentPath.js +6 -3
  30. package/lib/schema/array.js +3 -2
  31. package/lib/schema/boolean.js +4 -4
  32. package/lib/schema/buffer.js +3 -3
  33. package/lib/schema/date.js +7 -7
  34. package/lib/schema/decimal128.js +2 -2
  35. package/lib/schema/documentarray.js +17 -10
  36. package/lib/schema/mixed.js +2 -2
  37. package/lib/schema/number.js +6 -6
  38. package/lib/schema/objectid.js +4 -4
  39. package/lib/schema/string.js +14 -14
  40. package/lib/schema.js +28 -28
  41. package/lib/schematype.js +78 -68
  42. package/lib/types/ArraySubdocument.js +1 -1
  43. package/lib/types/DocumentArray/methods/index.js +2 -2
  44. package/lib/types/array/index.js +1 -1
  45. package/lib/types/array/methods/index.js +14 -12
  46. package/lib/types/buffer.js +1 -1
  47. package/lib/types/decimal128.js +1 -1
  48. package/lib/types/objectid.js +1 -1
  49. package/lib/types/subdocument.js +2 -2
  50. package/lib/virtualtype.js +4 -3
  51. package/package.json +18 -17
  52. package/tools/repl.js +8 -8
  53. package/tools/sharded.js +3 -3
  54. package/types/connection.d.ts +116 -116
  55. package/types/document.d.ts +3 -0
  56. package/types/error.d.ts +2 -2
  57. package/types/index.d.ts +75 -67
  58. package/types/pipelinestage.d.ts +194 -194
  59. package/types/schemaoptions.d.ts +2 -2
package/lib/index.js CHANGED
@@ -24,7 +24,6 @@ const legacyPluralize = require('./helpers/pluralize');
24
24
  const utils = require('./utils');
25
25
  const pkg = require('../package.json');
26
26
  const cast = require('./cast');
27
- const clearValidating = require('./plugins/clearValidating');
28
27
  const removeSubdocs = require('./plugins/removeSubdocs');
29
28
  const saveSubdocs = require('./plugins/saveSubdocs');
30
29
  const trackTransaction = require('./plugins/trackTransaction');
@@ -48,7 +47,7 @@ const objectIdHexRegexp = /^[0-9A-Fa-f]{24}$/;
48
47
  * The exports object of the `mongoose` module is an instance of this class.
49
48
  * Most apps will only use this one instance.
50
49
  *
51
- * ####Example:
50
+ * #### Example:
52
51
  * const mongoose = require('mongoose');
53
52
  * mongoose instanceof mongoose.Mongoose; // true
54
53
  *
@@ -107,8 +106,7 @@ function Mongoose(options) {
107
106
  [validateBeforeSave, { deduplicate: true }],
108
107
  [shardingPlugin, { deduplicate: true }],
109
108
  [removeSubdocs, { deduplicate: true }],
110
- [trackTransaction, { deduplicate: true }],
111
- [clearValidating, { deduplicate: true }]
109
+ [trackTransaction, { deduplicate: true }]
112
110
  ]
113
111
  });
114
112
  }
@@ -146,7 +144,7 @@ Mongoose.prototype.driver = driver;
146
144
  /**
147
145
  * Sets mongoose options
148
146
  *
149
- * ####Example:
147
+ * #### Example:
150
148
  *
151
149
  * mongoose.set('test', value) // sets the 'test' option to `value`
152
150
  *
@@ -209,7 +207,7 @@ Mongoose.prototype.set = function(key, value) {
209
207
  /**
210
208
  * Gets mongoose options
211
209
  *
212
- * ####Example:
210
+ * #### Example:
213
211
  *
214
212
  * mongoose.get('test') // returns the 'test' value
215
213
  *
@@ -228,7 +226,7 @@ Mongoose.prototype.get = Mongoose.prototype.set;
228
226
  *
229
227
  * _Options passed take precedence over options included in connection strings._
230
228
  *
231
- * ####Example:
229
+ * #### Example:
232
230
  *
233
231
  * // with mongodb:// URI
234
232
  * db = mongoose.createConnection('mongodb://user:pass@localhost:port/database');
@@ -292,7 +290,7 @@ Mongoose.prototype.createConnection = function(uri, options, callback) {
292
290
  /**
293
291
  * Opens the default mongoose connection.
294
292
  *
295
- * ####Example:
293
+ * #### Example:
296
294
  *
297
295
  * mongoose.connect('mongodb://user:pass@localhost:port/database');
298
296
  *
@@ -426,7 +424,7 @@ Mongoose.prototype.pluralize = function(fn) {
426
424
  * you will get an `OverwriteModelError`. If you call `mongoose.model()` with
427
425
  * the same name and same schema, you'll get the same schema back.
428
426
  *
429
- * ####Example:
427
+ * #### Example:
430
428
  *
431
429
  * const mongoose = require('mongoose');
432
430
  *
@@ -448,7 +446,7 @@ Mongoose.prototype.pluralize = function(fn) {
448
446
  *
449
447
  * _When no `collection` argument is passed, Mongoose uses the model name. If you don't like this behavior, either pass a collection name, use `mongoose.pluralize()`, or set your schemas collection name option._
450
448
  *
451
- * ####Example:
449
+ * #### Example:
452
450
  *
453
451
  * const schema = new Schema({ name: String }, { collection: 'actor' });
454
452
  *
@@ -579,7 +577,7 @@ Mongoose.prototype._model = function(name, schema, collection, options) {
579
577
  *
580
578
  * Equivalent to `mongoose.connection.deleteModel(name)`.
581
579
  *
582
- * ####Example:
580
+ * #### Example:
583
581
  *
584
582
  * mongoose.model('User', new Schema({ name: String }));
585
583
  * console.log(mongoose.model('User')); // Model object
@@ -607,7 +605,7 @@ Mongoose.prototype.deleteModel = function(name) {
607
605
  /**
608
606
  * Returns an array of model names created on this instance of Mongoose.
609
607
  *
610
- * ####Note:
608
+ * #### Note:
611
609
  *
612
610
  * _Does not include names of models created using `connection.model()`._
613
611
  *
@@ -660,7 +658,7 @@ Mongoose.prototype.plugin = function(fn, opts) {
660
658
  /**
661
659
  * The Mongoose module's default connection. Equivalent to `mongoose.connections[0]`, see [`connections`](#mongoose_Mongoose-connections).
662
660
  *
663
- * ####Example:
661
+ * #### Example:
664
662
  *
665
663
  * const mongoose = require('mongoose');
666
664
  * mongoose.connect(...);
@@ -693,7 +691,7 @@ Mongoose.prototype.__defineSetter__('connection', function(v) {
693
691
  * [`createConnection()`](#mongoose_Mongoose-createConnection) adds a connection
694
692
  * to this array.
695
693
  *
696
- * ####Example:
694
+ * #### Example:
697
695
  *
698
696
  * const mongoose = require('mongoose');
699
697
  * mongoose.connections.length; // 1, just the default connection
@@ -769,7 +767,7 @@ Mongoose.prototype.version = pkg.version;
769
767
  *
770
768
  * The exports of the mongoose module is an instance of this class.
771
769
  *
772
- * ####Example:
770
+ * #### Example:
773
771
  *
774
772
  * const mongoose = require('mongoose');
775
773
  * const mongoose2 = new mongoose.Mongoose();
@@ -783,7 +781,7 @@ Mongoose.prototype.Mongoose = Mongoose;
783
781
  /**
784
782
  * The Mongoose [Schema](#schema_Schema) constructor
785
783
  *
786
- * ####Example:
784
+ * #### Example:
787
785
  *
788
786
  * const mongoose = require('mongoose');
789
787
  * const Schema = mongoose.Schema;
@@ -807,7 +805,7 @@ Mongoose.prototype.SchemaType = SchemaType;
807
805
  /**
808
806
  * The various Mongoose SchemaTypes.
809
807
  *
810
- * ####Note:
808
+ * #### Note:
811
809
  *
812
810
  * _Alias of mongoose.Schema.Types for backwards compatibility._
813
811
  *
@@ -830,12 +828,12 @@ Mongoose.prototype.VirtualType = VirtualType;
830
828
  /**
831
829
  * The various Mongoose Types.
832
830
  *
833
- * ####Example:
831
+ * #### Example:
834
832
  *
835
833
  * const mongoose = require('mongoose');
836
834
  * const array = mongoose.Types.Array;
837
835
  *
838
- * ####Types:
836
+ * #### Types:
839
837
  *
840
838
  * - [Array](/docs/schematypes.html#arrays)
841
839
  * - [Buffer](/docs/schematypes.html#buffers)
@@ -928,7 +926,7 @@ Mongoose.prototype.DocumentProvider = require('./document_provider');
928
926
  * Do not use this to create a new ObjectId instance, use `mongoose.Types.ObjectId`
929
927
  * instead.
930
928
  *
931
- * ####Example:
929
+ * #### Example:
932
930
  *
933
931
  * const childSchema = new Schema({ parentId: mongoose.ObjectId });
934
932
  *
@@ -942,7 +940,7 @@ Mongoose.prototype.ObjectId = SchemaTypes.ObjectId;
942
940
  * Returns true if Mongoose can cast the given value to an ObjectId, or
943
941
  * false otherwise.
944
942
  *
945
- * ####Example:
943
+ * #### Example:
946
944
  *
947
945
  * mongoose.isValidObjectId(new mongoose.Types.ObjectId()); // true
948
946
  * mongoose.isValidObjectId('0123456789ab'); // true
@@ -973,7 +971,7 @@ Mongoose.prototype.isValidObjectId = function(v) {
973
971
  * `isObjectIdOrHexString()` returns true only for `ObjectId` instances or 24 character hex
974
972
  * strings, and will return false for numbers, documents, and strings of length 12.
975
973
  *
976
- * ####Example:
974
+ * #### Example:
977
975
  *
978
976
  * mongoose.isObjectIdOrHexString(new mongoose.Types.ObjectId()); // true
979
977
  * mongoose.isObjectIdOrHexString('62261a65d66c6be0a63c051f'); // true
@@ -1014,7 +1012,7 @@ Mongoose.prototype.syncIndexes = function(options) {
1014
1012
  * Do not use this to create a new Decimal128 instance, use `mongoose.Types.Decimal128`
1015
1013
  * instead.
1016
1014
  *
1017
- * ####Example:
1015
+ * #### Example:
1018
1016
  *
1019
1017
  * const vehicleSchema = new Schema({ fuelLevel: mongoose.Decimal128 });
1020
1018
  *
@@ -1029,7 +1027,7 @@ Mongoose.prototype.Decimal128 = SchemaTypes.Decimal128;
1029
1027
  * declaring paths in your schema that Mongoose's change tracking, casting,
1030
1028
  * and validation should ignore.
1031
1029
  *
1032
- * ####Example:
1030
+ * #### Example:
1033
1031
  *
1034
1032
  * const schema = new Schema({ arbitrary: mongoose.Mixed });
1035
1033
  *
@@ -1042,7 +1040,7 @@ Mongoose.prototype.Mixed = SchemaTypes.Mixed;
1042
1040
  /**
1043
1041
  * The Mongoose Date [SchemaType](/docs/schematypes.html).
1044
1042
  *
1045
- * ####Example:
1043
+ * #### Example:
1046
1044
  *
1047
1045
  * const schema = new Schema({ test: Date });
1048
1046
  * schema.path('test') instanceof mongoose.Date; // true
@@ -1057,7 +1055,7 @@ Mongoose.prototype.Date = SchemaTypes.Date;
1057
1055
  * The Mongoose Number [SchemaType](/docs/schematypes.html). Used for
1058
1056
  * declaring paths in your schema that Mongoose should cast to numbers.
1059
1057
  *
1060
- * ####Example:
1058
+ * #### Example:
1061
1059
  *
1062
1060
  * const schema = new Schema({ num: mongoose.Number });
1063
1061
  * // Equivalent to: