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.
Files changed (49) hide show
  1. package/.eslintrc.json +157 -157
  2. package/README.md +1 -1
  3. package/dist/browser.umd.js +2 -1704
  4. package/lib/aggregate.js +4 -3
  5. package/lib/collection.js +0 -7
  6. package/lib/connection.js +2 -1
  7. package/lib/cursor/ChangeStream.js +42 -2
  8. package/lib/cursor/QueryCursor.js +2 -0
  9. package/lib/document.js +22 -26
  10. package/lib/error/cast.js +8 -2
  11. package/lib/error/eachAsyncMultiError.js +41 -0
  12. package/lib/helpers/common.js +0 -8
  13. package/lib/helpers/cursor/eachAsync.js +44 -12
  14. package/lib/helpers/immediate.js +3 -1
  15. package/lib/helpers/isAsyncFunction.js +19 -7
  16. package/lib/helpers/model/discriminator.js +1 -3
  17. package/lib/helpers/populate/getModelsMapForPopulate.js +13 -10
  18. package/lib/helpers/query/applyGlobalOption.js +29 -0
  19. package/lib/helpers/schematype/handleImmutable.js +4 -1
  20. package/lib/helpers/timestamps/setupTimestamps.js +2 -2
  21. package/lib/index.js +11 -4
  22. package/lib/internal.js +0 -1
  23. package/lib/model.js +39 -27
  24. package/lib/query.js +23 -4
  25. package/lib/queryhelpers.js +11 -1
  26. package/lib/schema/SubdocumentPath.js +3 -15
  27. package/lib/schema/documentarray.js +7 -7
  28. package/lib/schema/number.js +1 -5
  29. package/lib/schema/objectid.js +2 -4
  30. package/lib/schema/string.js +1 -5
  31. package/lib/schema.js +115 -2
  32. package/lib/schematype.js +2 -2
  33. package/lib/types/DocumentArray/methods/index.js +9 -1
  34. package/lib/types/array/methods/index.js +8 -9
  35. package/lib/validoptions.js +1 -0
  36. package/package.json +25 -18
  37. package/tools/repl.js +2 -1
  38. package/tsconfig.json +2 -2
  39. package/types/aggregate.d.ts +1 -2
  40. package/types/connection.d.ts +4 -5
  41. package/types/cursor.d.ts +13 -6
  42. package/types/document.d.ts +17 -14
  43. package/types/error.d.ts +124 -124
  44. package/types/index.d.ts +350 -202
  45. package/types/mongooseoptions.d.ts +11 -6
  46. package/types/schemaoptions.d.ts +1 -2
  47. package/CHANGELOG.md +0 -7238
  48. package/History.md +0 -1
  49. 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
- "eslint:recommended"
4
- ],
5
- "ignorePatterns": [
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
- "mocha-no-only"
46
- ],
47
- "parserOptions": {
48
- "ecmaVersion": 2020
49
- },
50
- "env": {
51
- "node": true,
52
- "es6": true
53
- },
19
+ "@typescript-eslint"
20
+ ],
54
21
  "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"
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 Mongoose will create the model for your __tickets__ collection, not your __ticket__ collection.
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