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.
- package/.eslintrc.json +35 -26
- package/CHANGELOG.md +27 -0
- package/dist/browser.umd.js +71 -71
- package/lib/aggregate.js +36 -36
- package/lib/browser.js +4 -4
- package/lib/browserDocument.js +1 -0
- package/lib/connection.js +21 -21
- package/lib/cursor/AggregationCursor.js +2 -3
- package/lib/cursor/QueryCursor.js +3 -3
- package/lib/document.js +75 -47
- package/lib/error/index.js +2 -2
- package/lib/helpers/document/handleSpreadDoc.js +19 -1
- package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/lib/helpers/query/castFilterPath.js +0 -1
- package/lib/index.js +24 -26
- package/lib/model.js +141 -136
- package/lib/options/SchemaArrayOptions.js +2 -2
- package/lib/options/SchemaBufferOptions.js +1 -1
- package/lib/options/SchemaDateOptions.js +9 -2
- package/lib/options/SchemaDocumentArrayOptions.js +3 -3
- package/lib/options/SchemaMapOptions.js +2 -2
- package/lib/options/SchemaNumberOptions.js +3 -3
- package/lib/options/SchemaObjectIdOptions.js +2 -2
- package/lib/options/SchemaStringOptions.js +1 -1
- package/lib/options/SchemaSubdocumentOptions.js +2 -2
- package/lib/options/SchemaTypeOptions.js +3 -3
- package/lib/query.js +253 -225
- package/lib/schema/SubdocumentPath.js +6 -3
- package/lib/schema/array.js +3 -2
- package/lib/schema/boolean.js +4 -4
- package/lib/schema/buffer.js +3 -3
- package/lib/schema/date.js +7 -7
- package/lib/schema/decimal128.js +2 -2
- package/lib/schema/documentarray.js +17 -10
- package/lib/schema/mixed.js +2 -2
- package/lib/schema/number.js +6 -6
- package/lib/schema/objectid.js +4 -4
- package/lib/schema/string.js +14 -14
- package/lib/schema.js +28 -28
- package/lib/schematype.js +78 -68
- package/lib/types/ArraySubdocument.js +1 -1
- package/lib/types/DocumentArray/methods/index.js +2 -2
- package/lib/types/array/index.js +1 -1
- package/lib/types/array/methods/index.js +14 -12
- package/lib/types/buffer.js +1 -1
- package/lib/types/decimal128.js +1 -1
- package/lib/types/objectid.js +1 -1
- package/lib/types/subdocument.js +2 -2
- package/lib/virtualtype.js +4 -3
- package/package.json +18 -17
- package/tools/repl.js +8 -8
- package/tools/sharded.js +3 -3
- package/types/connection.d.ts +116 -116
- package/types/document.d.ts +3 -0
- package/types/error.d.ts +2 -2
- package/types/index.d.ts +75 -67
- package/types/pipelinestage.d.ts +194 -194
- 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: {
|