mongoose 6.3.0 → 6.3.3

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 (42) hide show
  1. package/.eslintrc.json +157 -157
  2. package/README.md +2 -2
  3. package/dist/browser.umd.js +1 -1
  4. package/lib/collection.js +0 -7
  5. package/lib/connection.js +2 -1
  6. package/lib/document.js +65 -68
  7. package/lib/error/cast.js +8 -2
  8. package/lib/helpers/common.js +0 -8
  9. package/lib/helpers/immediate.js +3 -1
  10. package/lib/helpers/isAsyncFunction.js +19 -7
  11. package/lib/helpers/model/castBulkWrite.js +12 -0
  12. package/lib/helpers/populate/getModelsMapForPopulate.js +13 -10
  13. package/lib/helpers/query/cast$expr.js +4 -1
  14. package/lib/helpers/schematype/handleImmutable.js +4 -1
  15. package/lib/helpers/timestamps/setupTimestamps.js +2 -2
  16. package/lib/index.js +1 -1
  17. package/lib/internal.js +0 -1
  18. package/lib/model.js +42 -28
  19. package/lib/query.js +7 -3
  20. package/lib/queryhelpers.js +11 -1
  21. package/lib/schema/SubdocumentPath.js +3 -15
  22. package/lib/schema/documentarray.js +7 -7
  23. package/lib/schema/number.js +1 -5
  24. package/lib/schema/objectid.js +2 -4
  25. package/lib/schema/string.js +3 -6
  26. package/lib/schema.js +1 -1
  27. package/lib/schematype.js +2 -2
  28. package/lib/types/DocumentArray/methods/index.js +9 -1
  29. package/lib/types/array/methods/index.js +8 -9
  30. package/lib/utils.js +4 -0
  31. package/package.json +39 -19
  32. package/tsconfig.json +2 -2
  33. package/types/aggregate.d.ts +1 -2
  34. package/types/connection.d.ts +4 -5
  35. package/types/cursor.d.ts +3 -2
  36. package/types/document.d.ts +18 -15
  37. package/types/error.d.ts +124 -124
  38. package/types/index.d.ts +182 -154
  39. package/types/mongooseoptions.d.ts +1 -2
  40. package/types/schemaoptions.d.ts +1 -2
  41. package/CHANGELOG.md +0 -7249
  42. package/History.md +0 -1
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment. Mongoose supports both promises and callbacks.
4
4
 
5
- [![Slack Status](http://slack.mongoosejs.io/badge.svg)](http://slack.mongoosejs.io)
5
+ [![Slack Status](https://img.shields.io/badge/slack-mongoosejsteam-34D058.svg?logo=slack )](https://mongoosejsteam.slack.com)
6
6
  [![Build Status](https://github.com/Automattic/mongoose/workflows/Test/badge.svg)](https://github.com/Automattic/mongoose)
7
7
  [![NPM version](https://badge.fury.io/js/mongoose.svg)](http://badge.fury.io/js/mongoose)
8
8
 
@@ -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