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
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on an Array schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ tags: [String] });
11
11
  * schema.path('tags').options; // SchemaArrayOptions instance
@@ -36,7 +36,7 @@ Object.defineProperty(SchemaArrayOptions.prototype, 'enum', opts);
36
36
  * If set, specifies the type of this array's values. Equivalent to setting
37
37
  * `type` to an array whose first element is `of`.
38
38
  *
39
- * ####Example:
39
+ * #### Example:
40
40
  *
41
41
  * // `arr` is an array of numbers.
42
42
  * new Schema({ arr: [Number] });
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on a Buffer schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ bitmap: Buffer });
11
11
  * schema.path('bitmap').options; // SchemaBufferOptions instance
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on a Date schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ startedAt: Date });
11
11
  * schema.path('startedAt').options; // SchemaDateOptions instance
@@ -48,6 +48,13 @@ Object.defineProperty(SchemaDateOptions.prototype, 'max', opts);
48
48
  /**
49
49
  * If set, Mongoose creates a TTL index on this path.
50
50
  *
51
+ * mongo TTL index `expireAfterSeconds` value will take 'expires' value expressed in seconds.
52
+ *
53
+ * #### Example:
54
+ *
55
+ * const schema = new Schema({ "expireAt": { type: Date, expires: 11 } });
56
+ * // if 'expireAt' is set, then document expires at expireAt + 11 seconds
57
+ *
51
58
  * @api public
52
59
  * @property expires
53
60
  * @memberOf SchemaDateOptions
@@ -61,4 +68,4 @@ Object.defineProperty(SchemaDateOptions.prototype, 'expires', opts);
61
68
  * ignore
62
69
  */
63
70
 
64
- module.exports = SchemaDateOptions;
71
+ module.exports = SchemaDateOptions;
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on an Document Array schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ users: [{ name: string }] });
11
11
  * schema.path('users').options; // SchemaDocumentArrayOptions instance
@@ -23,7 +23,7 @@ const opts = require('./propertyOptions');
23
23
  * If `true`, Mongoose will skip building any indexes defined in this array's schema.
24
24
  * If not set, Mongoose will build all indexes defined in this array's schema.
25
25
  *
26
- * ####Example:
26
+ * #### Example:
27
27
  *
28
28
  * const childSchema = Schema({ name: { type: String, index: true } });
29
29
  * // If `excludeIndexes` is `true`, Mongoose will skip building an index
@@ -44,7 +44,7 @@ Object.defineProperty(SchemaDocumentArrayOptions.prototype, 'excludeIndexes', op
44
44
  /**
45
45
  * If set, overwrites the child schema's `_id` option.
46
46
  *
47
- * ####Example:
47
+ * #### Example:
48
48
  *
49
49
  * const childSchema = Schema({ name: String });
50
50
  * const parentSchema = Schema({
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on a Map schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ socialMediaHandles: { type: Map, of: String } });
11
11
  * schema.path('socialMediaHandles').options; // SchemaMapOptions instance
@@ -25,7 +25,7 @@ const opts = require('./propertyOptions');
25
25
  *
26
26
  * If not set, Mongoose will not cast the map's values.
27
27
  *
28
- * ####Example:
28
+ * #### Example:
29
29
  *
30
30
  * // Mongoose will cast `socialMediaHandles` values to strings
31
31
  * const schema = new Schema({ socialMediaHandles: { type: Map, of: String } });
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on a Number schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ count: Number });
11
11
  * schema.path('count').options; // SchemaNumberOptions instance
@@ -49,7 +49,7 @@ Object.defineProperty(SchemaNumberOptions.prototype, 'max', opts);
49
49
  * If set, Mongoose adds a validator that checks that this path is strictly
50
50
  * equal to one of the given values.
51
51
  *
52
- * ####Example:
52
+ * #### Example:
53
53
  * const schema = new Schema({
54
54
  * favoritePrime: {
55
55
  * type: Number,
@@ -70,7 +70,7 @@ Object.defineProperty(SchemaNumberOptions.prototype, 'enum', opts);
70
70
  /**
71
71
  * Sets default [populate options](/docs/populate.html#query-conditions).
72
72
  *
73
- * ####Example:
73
+ * #### Example:
74
74
  * const schema = new Schema({
75
75
  * child: {
76
76
  * type: Number,
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on an ObjectId schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ testId: mongoose.ObjectId });
11
11
  * schema.path('testId').options; // SchemaObjectIdOptions instance
@@ -34,7 +34,7 @@ Object.defineProperty(SchemaObjectIdOptions.prototype, 'auto', opts);
34
34
  /**
35
35
  * Sets default [populate options](/docs/populate.html#query-conditions).
36
36
  *
37
- * ####Example:
37
+ * #### Example:
38
38
  * const schema = new Schema({
39
39
  * child: {
40
40
  * type: 'ObjectId',
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on a string schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ name: String });
11
11
  * schema.path('name').options; // SchemaStringOptions instance
@@ -5,7 +5,7 @@ const SchemaTypeOptions = require('./SchemaTypeOptions');
5
5
  /**
6
6
  * The options defined on a single nested schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = Schema({ child: Schema({ name: String }) });
11
11
  * schema.path('child').options; // SchemaSubdocumentOptions instance
@@ -22,7 +22,7 @@ const opts = require('./propertyOptions');
22
22
  /**
23
23
  * If set, overwrites the child schema's `_id` option.
24
24
  *
25
- * ####Example:
25
+ * #### Example:
26
26
  *
27
27
  * const childSchema = Schema({ name: String });
28
28
  * const parentSchema = Schema({
@@ -5,7 +5,7 @@ const clone = require('../helpers/clone');
5
5
  /**
6
6
  * The options defined on a schematype.
7
7
  *
8
- * ####Example:
8
+ * #### Example:
9
9
  *
10
10
  * const schema = new Schema({ name: String });
11
11
  * schema.path('name').options instanceof mongoose.SchemaTypeOptions; // true
@@ -53,7 +53,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'validate', opts);
53
53
  * Allows overriding casting logic for this individual path. If a string, the
54
54
  * given string overwrites Mongoose's default cast error message.
55
55
  *
56
- * ####Example:
56
+ * #### Example:
57
57
  *
58
58
  * const schema = new Schema({
59
59
  * num: {
@@ -203,7 +203,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'text', opts);
203
203
  * Define a transform function for this individual schema type.
204
204
  * Only called when calling `toJSON()` or `toObject()`.
205
205
  *
206
- * ####Example:
206
+ * #### Example:
207
207
  *
208
208
  * const schema = Schema({
209
209
  * myDate: {