mongoose 6.2.11 → 6.3.2
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 +157 -157
- package/README.md +1 -1
- package/dist/browser.umd.js +2 -1704
- package/lib/aggregate.js +4 -3
- package/lib/collection.js +0 -7
- package/lib/connection.js +2 -1
- package/lib/cursor/ChangeStream.js +42 -2
- package/lib/cursor/QueryCursor.js +2 -0
- package/lib/document.js +22 -26
- package/lib/error/cast.js +8 -2
- package/lib/error/eachAsyncMultiError.js +41 -0
- package/lib/helpers/common.js +0 -8
- package/lib/helpers/cursor/eachAsync.js +44 -12
- package/lib/helpers/immediate.js +3 -1
- package/lib/helpers/isAsyncFunction.js +19 -7
- package/lib/helpers/model/discriminator.js +1 -3
- package/lib/helpers/populate/getModelsMapForPopulate.js +13 -10
- package/lib/helpers/query/applyGlobalOption.js +29 -0
- package/lib/helpers/schematype/handleImmutable.js +4 -1
- package/lib/helpers/timestamps/setupTimestamps.js +2 -2
- package/lib/index.js +11 -4
- package/lib/internal.js +0 -1
- package/lib/model.js +39 -27
- package/lib/query.js +23 -4
- package/lib/queryhelpers.js +11 -1
- package/lib/schema/SubdocumentPath.js +3 -15
- package/lib/schema/documentarray.js +7 -7
- package/lib/schema/number.js +1 -5
- package/lib/schema/objectid.js +2 -4
- package/lib/schema/string.js +1 -5
- package/lib/schema.js +115 -2
- package/lib/schematype.js +2 -2
- package/lib/types/DocumentArray/methods/index.js +9 -1
- package/lib/types/array/methods/index.js +8 -9
- package/lib/validoptions.js +1 -0
- package/package.json +25 -18
- package/tools/repl.js +2 -1
- package/tsconfig.json +2 -2
- package/types/aggregate.d.ts +1 -2
- package/types/connection.d.ts +4 -5
- package/types/cursor.d.ts +13 -6
- package/types/document.d.ts +17 -14
- package/types/error.d.ts +124 -124
- package/types/index.d.ts +350 -202
- package/types/mongooseoptions.d.ts +11 -6
- package/types/schemaoptions.d.ts +1 -2
- package/CHANGELOG.md +0 -7238
- package/History.md +0 -1
- package/lib/helpers/query/applyGlobalMaxTimeMS.js +0 -15
package/.eslintrc.json
CHANGED
|
@@ -1,163 +1,163 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"eslint:recommended"
|
|
4
|
+
],
|
|
5
|
+
"ignorePatterns": [
|
|
6
|
+
"docs",
|
|
7
|
+
"dist",
|
|
8
|
+
"test/files/*"
|
|
9
|
+
],
|
|
10
|
+
"overrides": [{
|
|
11
|
+
"files": [
|
|
12
|
+
"**/*.{ts,tsx}"
|
|
13
|
+
],
|
|
2
14
|
"extends": [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"docs",
|
|
7
|
-
"dist",
|
|
8
|
-
"test/files/*"
|
|
9
|
-
],
|
|
10
|
-
"overrides": [{
|
|
11
|
-
"files": [
|
|
12
|
-
"**/*.{ts,tsx}"
|
|
13
|
-
],
|
|
14
|
-
"extends": [
|
|
15
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
16
|
-
"plugin:@typescript-eslint/recommended"
|
|
17
|
-
],
|
|
18
|
-
"plugins": [
|
|
19
|
-
"@typescript-eslint"
|
|
20
|
-
],
|
|
21
|
-
"rules": {
|
|
22
|
-
"@typescript-eslint/triple-slash-reference": "off",
|
|
23
|
-
"spaced-comment": ["error", "always", {
|
|
24
|
-
"markers": ["/"]
|
|
25
|
-
}],
|
|
26
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
27
|
-
"@typescript-eslint/ban-types": "off",
|
|
28
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
29
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
30
|
-
"@typescript-eslint/indent": ["error", 2, {
|
|
31
|
-
"SwitchCase": 1
|
|
32
|
-
}],
|
|
33
|
-
"@typescript-eslint/prefer-optional-chain": "error",
|
|
34
|
-
"@typescript-eslint/brace-style": "error",
|
|
35
|
-
"@typescript-eslint/no-dupe-class-members": "error",
|
|
36
|
-
"@typescript-eslint/no-redeclare": "error",
|
|
37
|
-
"@typescript-eslint/type-annotation-spacing": "error",
|
|
38
|
-
"@typescript-eslint/object-curly-spacing": ["error", "always"],
|
|
39
|
-
"@typescript-eslint/semi": "error",
|
|
40
|
-
"@typescript-eslint/space-before-function-paren": ["error", "never"],
|
|
41
|
-
"@typescript-eslint/space-infix-ops": "error"
|
|
42
|
-
}
|
|
43
|
-
}],
|
|
15
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
16
|
+
"plugin:@typescript-eslint/recommended"
|
|
17
|
+
],
|
|
44
18
|
"plugins": [
|
|
45
|
-
|
|
46
|
-
],
|
|
47
|
-
"parserOptions": {
|
|
48
|
-
"ecmaVersion": 2020
|
|
49
|
-
},
|
|
50
|
-
"env": {
|
|
51
|
-
"node": true,
|
|
52
|
-
"es6": true
|
|
53
|
-
},
|
|
19
|
+
"@typescript-eslint"
|
|
20
|
+
],
|
|
54
21
|
"rules": {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"no-useless-rename": "error",
|
|
76
|
-
"no-dupe-keys": "error",
|
|
77
|
-
"space-in-parens": [
|
|
78
|
-
"error",
|
|
79
|
-
"never"
|
|
80
|
-
],
|
|
81
|
-
"spaced-comment": [
|
|
82
|
-
"error",
|
|
83
|
-
"always",
|
|
84
|
-
{
|
|
85
|
-
"block": {
|
|
86
|
-
"markers": [
|
|
87
|
-
"!"
|
|
88
|
-
],
|
|
89
|
-
"balanced": true
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
"key-spacing": [
|
|
94
|
-
"error",
|
|
95
|
-
{
|
|
96
|
-
"beforeColon": false,
|
|
97
|
-
"afterColon": true
|
|
98
|
-
}
|
|
99
|
-
],
|
|
100
|
-
"comma-spacing": [
|
|
101
|
-
"error",
|
|
102
|
-
{
|
|
103
|
-
"before": false,
|
|
104
|
-
"after": true
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
"array-bracket-spacing": 1,
|
|
108
|
-
"arrow-spacing": [
|
|
109
|
-
"error",
|
|
110
|
-
{
|
|
111
|
-
"before": true,
|
|
112
|
-
"after": true
|
|
113
|
-
}
|
|
114
|
-
],
|
|
115
|
-
"object-curly-spacing": [
|
|
116
|
-
"error",
|
|
117
|
-
"always"
|
|
118
|
-
],
|
|
119
|
-
"comma-dangle": [
|
|
120
|
-
"error",
|
|
121
|
-
"never"
|
|
122
|
-
],
|
|
123
|
-
"no-unreachable": "error",
|
|
124
|
-
"quotes": [
|
|
125
|
-
"error",
|
|
126
|
-
"single"
|
|
127
|
-
],
|
|
128
|
-
"quote-props": [
|
|
129
|
-
"error",
|
|
130
|
-
"as-needed"
|
|
131
|
-
],
|
|
132
|
-
"semi": "error",
|
|
133
|
-
"no-extra-semi": "error",
|
|
134
|
-
"semi-spacing": "error",
|
|
135
|
-
"no-spaced-func": "error",
|
|
136
|
-
"no-throw-literal": "error",
|
|
137
|
-
"space-before-blocks": "error",
|
|
138
|
-
"space-before-function-paren": [
|
|
139
|
-
"error",
|
|
140
|
-
"never"
|
|
141
|
-
],
|
|
142
|
-
"space-infix-ops": "error",
|
|
143
|
-
"space-unary-ops": "error",
|
|
144
|
-
"no-var": "warn",
|
|
145
|
-
"prefer-const": "warn",
|
|
146
|
-
"strict": [
|
|
147
|
-
"error",
|
|
148
|
-
"global"
|
|
149
|
-
],
|
|
150
|
-
"no-restricted-globals": [
|
|
151
|
-
"error",
|
|
152
|
-
{
|
|
153
|
-
"name": "context",
|
|
154
|
-
"message": "Don't use Mocha's global context"
|
|
155
|
-
}
|
|
156
|
-
],
|
|
157
|
-
"no-prototype-builtins": "off",
|
|
158
|
-
"mocha-no-only/mocha-no-only": [
|
|
159
|
-
"error"
|
|
160
|
-
],
|
|
161
|
-
"no-empty": "off"
|
|
22
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
23
|
+
"spaced-comment": ["error", "always", {
|
|
24
|
+
"markers": ["/"]
|
|
25
|
+
}],
|
|
26
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
27
|
+
"@typescript-eslint/ban-types": "off",
|
|
28
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
29
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
30
|
+
"@typescript-eslint/indent": ["error", 2, {
|
|
31
|
+
"SwitchCase": 1
|
|
32
|
+
}],
|
|
33
|
+
"@typescript-eslint/prefer-optional-chain": "error",
|
|
34
|
+
"@typescript-eslint/brace-style": "error",
|
|
35
|
+
"@typescript-eslint/no-dupe-class-members": "error",
|
|
36
|
+
"@typescript-eslint/no-redeclare": "error",
|
|
37
|
+
"@typescript-eslint/type-annotation-spacing": "error",
|
|
38
|
+
"@typescript-eslint/object-curly-spacing": ["error", "always"],
|
|
39
|
+
"@typescript-eslint/semi": "error",
|
|
40
|
+
"@typescript-eslint/space-before-function-paren": ["error", "never"],
|
|
41
|
+
"@typescript-eslint/space-infix-ops": "error"
|
|
162
42
|
}
|
|
43
|
+
}],
|
|
44
|
+
"plugins": [
|
|
45
|
+
"mocha-no-only"
|
|
46
|
+
],
|
|
47
|
+
"parserOptions": {
|
|
48
|
+
"ecmaVersion": 2020
|
|
49
|
+
},
|
|
50
|
+
"env": {
|
|
51
|
+
"node": true,
|
|
52
|
+
"es6": true
|
|
53
|
+
},
|
|
54
|
+
"rules": {
|
|
55
|
+
"comma-style": "error",
|
|
56
|
+
"indent": [
|
|
57
|
+
"error",
|
|
58
|
+
2,
|
|
59
|
+
{
|
|
60
|
+
"SwitchCase": 1,
|
|
61
|
+
"VariableDeclarator": 2
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"keyword-spacing": "error",
|
|
65
|
+
"no-whitespace-before-property": "error",
|
|
66
|
+
"no-buffer-constructor": "warn",
|
|
67
|
+
"no-console": "off",
|
|
68
|
+
"no-constant-condition": "off",
|
|
69
|
+
"no-multi-spaces": "error",
|
|
70
|
+
"func-call-spacing": "error",
|
|
71
|
+
"no-trailing-spaces": "error",
|
|
72
|
+
"no-undef": "error",
|
|
73
|
+
"no-unneeded-ternary": "error",
|
|
74
|
+
"no-const-assign": "error",
|
|
75
|
+
"no-useless-rename": "error",
|
|
76
|
+
"no-dupe-keys": "error",
|
|
77
|
+
"space-in-parens": [
|
|
78
|
+
"error",
|
|
79
|
+
"never"
|
|
80
|
+
],
|
|
81
|
+
"spaced-comment": [
|
|
82
|
+
"error",
|
|
83
|
+
"always",
|
|
84
|
+
{
|
|
85
|
+
"block": {
|
|
86
|
+
"markers": [
|
|
87
|
+
"!"
|
|
88
|
+
],
|
|
89
|
+
"balanced": true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"key-spacing": [
|
|
94
|
+
"error",
|
|
95
|
+
{
|
|
96
|
+
"beforeColon": false,
|
|
97
|
+
"afterColon": true
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"comma-spacing": [
|
|
101
|
+
"error",
|
|
102
|
+
{
|
|
103
|
+
"before": false,
|
|
104
|
+
"after": true
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"array-bracket-spacing": 1,
|
|
108
|
+
"arrow-spacing": [
|
|
109
|
+
"error",
|
|
110
|
+
{
|
|
111
|
+
"before": true,
|
|
112
|
+
"after": true
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"object-curly-spacing": [
|
|
116
|
+
"error",
|
|
117
|
+
"always"
|
|
118
|
+
],
|
|
119
|
+
"comma-dangle": [
|
|
120
|
+
"error",
|
|
121
|
+
"never"
|
|
122
|
+
],
|
|
123
|
+
"no-unreachable": "error",
|
|
124
|
+
"quotes": [
|
|
125
|
+
"error",
|
|
126
|
+
"single"
|
|
127
|
+
],
|
|
128
|
+
"quote-props": [
|
|
129
|
+
"error",
|
|
130
|
+
"as-needed"
|
|
131
|
+
],
|
|
132
|
+
"semi": "error",
|
|
133
|
+
"no-extra-semi": "error",
|
|
134
|
+
"semi-spacing": "error",
|
|
135
|
+
"no-spaced-func": "error",
|
|
136
|
+
"no-throw-literal": "error",
|
|
137
|
+
"space-before-blocks": "error",
|
|
138
|
+
"space-before-function-paren": [
|
|
139
|
+
"error",
|
|
140
|
+
"never"
|
|
141
|
+
],
|
|
142
|
+
"space-infix-ops": "error",
|
|
143
|
+
"space-unary-ops": "error",
|
|
144
|
+
"no-var": "warn",
|
|
145
|
+
"prefer-const": "warn",
|
|
146
|
+
"strict": [
|
|
147
|
+
"error",
|
|
148
|
+
"global"
|
|
149
|
+
],
|
|
150
|
+
"no-restricted-globals": [
|
|
151
|
+
"error",
|
|
152
|
+
{
|
|
153
|
+
"name": "context",
|
|
154
|
+
"message": "Don't use Mocha's global context"
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"no-prototype-builtins": "off",
|
|
158
|
+
"mocha-no-only/mocha-no-only": [
|
|
159
|
+
"error"
|
|
160
|
+
],
|
|
161
|
+
"no-empty": "off"
|
|
162
|
+
}
|
|
163
163
|
}
|
package/README.md
CHANGED
|
@@ -153,7 +153,7 @@ The first argument is the _singular_ name of the collection your model is for. *
|
|
|
153
153
|
const MyModel = mongoose.model('Ticket', mySchema);
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
Then
|
|
156
|
+
Then `MyModel` will use the __tickets__ collection, not the __ticket__ collection. For more details read the [model docs](https://mongoosejs.com/docs/api/mongoose.html#mongoose_Mongoose-model).
|
|
157
157
|
|
|
158
158
|
Once we have our model, we can then instantiate it, and save it:
|
|
159
159
|
|