mongoose 6.1.8 → 6.2.1

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 (55) hide show
  1. package/.eslintrc.json +150 -0
  2. package/CHANGELOG.md +50 -0
  3. package/dist/browser.umd.js +191 -187
  4. package/lib/aggregate.js +1 -1
  5. package/lib/cast/objectid.js +1 -2
  6. package/lib/cast.js +21 -8
  7. package/lib/connection.js +33 -3
  8. package/lib/document.js +84 -65
  9. package/lib/error/index.js +11 -0
  10. package/lib/error/syncIndexes.js +30 -0
  11. package/lib/helpers/clone.js +40 -27
  12. package/lib/helpers/common.js +2 -2
  13. package/lib/helpers/getFunctionName.js +6 -4
  14. package/lib/helpers/isMongooseObject.js +9 -8
  15. package/lib/helpers/isObject.js +4 -4
  16. package/lib/helpers/model/discriminator.js +2 -1
  17. package/lib/helpers/path/parentPaths.js +10 -5
  18. package/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -2
  19. package/lib/helpers/populate/assignVals.js +8 -4
  20. package/lib/helpers/populate/getModelsMapForPopulate.js +6 -6
  21. package/lib/helpers/populate/markArraySubdocsPopulated.js +3 -1
  22. package/lib/helpers/populate/modelNamesFromRefPath.js +6 -5
  23. package/lib/helpers/query/cast$expr.js +284 -0
  24. package/lib/helpers/query/castUpdate.js +6 -2
  25. package/lib/helpers/schema/applyPlugins.js +11 -0
  26. package/lib/helpers/schema/getPath.js +4 -2
  27. package/lib/helpers/setDefaultsOnInsert.js +16 -7
  28. package/lib/helpers/timestamps/setupTimestamps.js +3 -8
  29. package/lib/helpers/update/applyTimestampsToChildren.js +2 -2
  30. package/lib/helpers/update/castArrayFilters.js +1 -1
  31. package/lib/helpers/update/updatedPathsByArrayFilter.js +1 -1
  32. package/lib/index.js +16 -40
  33. package/lib/internal.js +1 -1
  34. package/lib/model.js +37 -18
  35. package/lib/plugins/trackTransaction.js +4 -3
  36. package/lib/query.js +15 -13
  37. package/lib/queryhelpers.js +1 -1
  38. package/lib/schema/SubdocumentPath.js +1 -1
  39. package/lib/schema/array.js +18 -16
  40. package/lib/schema/documentarray.js +6 -9
  41. package/lib/schema/objectid.js +1 -1
  42. package/lib/schema.js +5 -4
  43. package/lib/schematype.js +74 -26
  44. package/lib/types/ArraySubdocument.js +2 -1
  45. package/lib/types/DocumentArray/index.js +9 -26
  46. package/lib/types/DocumentArray/isMongooseDocumentArray.js +5 -0
  47. package/lib/types/DocumentArray/methods/index.js +15 -3
  48. package/lib/types/array/index.js +21 -20
  49. package/lib/types/array/isMongooseArray.js +5 -0
  50. package/lib/types/array/methods/index.js +12 -12
  51. package/lib/utils.js +15 -8
  52. package/package.json +24 -156
  53. package/tools/repl.js +1 -1
  54. package/tsconfig.json +10 -0
  55. package/{index.d.ts → types/index.d.ts} +146 -86
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "6.1.8",
4
+ "version": "6.2.1",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -19,14 +19,12 @@
19
19
  ],
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@types/node": "< 17.0.6",
23
22
  "bson": "^4.2.2",
24
23
  "kareem": "2.3.3",
25
- "mongodb": "4.2.2",
24
+ "mongodb": "4.3.1",
26
25
  "mpath": "0.8.4",
27
26
  "mquery": "4.0.2",
28
27
  "ms": "2.1.2",
29
- "regexp-clone": "1.0.0",
30
28
  "sift": "13.5.2"
31
29
  },
32
30
  "devDependencies": {
@@ -40,28 +38,27 @@
40
38
  "babel-loader": "8.1.0",
41
39
  "benchmark": "2.1.4",
42
40
  "bluebird": "3.7.2",
43
- "chalk": "4.1.2",
44
41
  "cheerio": "1.0.0-rc.5",
45
42
  "dox": "0.3.1",
46
43
  "eslint": "8.5.0",
47
44
  "eslint-plugin-mocha-no-only": "1.1.0",
48
45
  "highlight.js": "9.18.3",
46
+ "js-yaml": "4.1.0",
49
47
  "lodash.isequal": "4.5.0",
50
48
  "lodash.isequalwith": "4.4.0",
51
49
  "marked": "2.1.3",
52
50
  "mkdirp": "0.5.5",
53
- "mocha": "9.1.3",
51
+ "mocha": "9.2.0",
54
52
  "moment": "2.x",
55
53
  "mongodb-memory-server": "^8.2.0",
56
- "object-sizeof": "1.3.0",
54
+ "nyc": "^15.1.0",
57
55
  "pug": "3.0.2",
58
56
  "q": "1.5.1",
59
57
  "rimraf": "2.6.3",
60
- "semver": "5.5.0",
61
58
  "serve-handler": "6.1.3",
59
+ "tsd": "0.19.1",
62
60
  "typescript": "4.5.3",
63
- "uuid": "2.0.3",
64
- "uuid-parse": "1.0.0",
61
+ "uuid": "8.3.2",
65
62
  "webpack": "4.44.1"
66
63
  },
67
64
  "directories": {
@@ -74,12 +71,14 @@
74
71
  "release": "git pull && git push origin master --tags && npm publish",
75
72
  "release-legacy": "git pull origin 5.x && git push origin 5.x --tags && npm publish --tag legacy",
76
73
  "mongo": "node ./tools/repl.js",
77
- "test": "mocha --exit ./test/*.test.js ./test/typescript/main.test.js",
74
+ "test": "mocha --exit ./test/*.test.js",
75
+ "test-tsd": "tsd",
76
+ "sym-link-mongoose": "npm link && npm link mongoose",
78
77
  "tdd": "mocha ./test/*.test.js ./test/typescript/main.test.js --inspect --watch --recursive --watch-files ./**/*.js",
79
- "test-cov": "nyc --reporter=html --reporter=text npm test"
78
+ "test-coverage": "nyc --reporter=html --reporter=text npm test"
80
79
  },
81
80
  "main": "./index.js",
82
- "types": "./index.d.ts",
81
+ "types": "./types/index.d.ts",
83
82
  "engines": {
84
83
  "node": ">=12.0.0"
85
84
  },
@@ -100,149 +99,6 @@
100
99
  "test/**/*.js"
101
100
  ]
102
101
  },
103
- "eslintConfig": {
104
- "extends": [
105
- "eslint:recommended"
106
- ],
107
- "overrides": [
108
- {
109
- "files": [
110
- "**/*.{ts,tsx}"
111
- ],
112
- "extends": [
113
- "plugin:@typescript-eslint/eslint-recommended",
114
- "plugin:@typescript-eslint/recommended"
115
- ],
116
- "plugins": [
117
- "@typescript-eslint"
118
- ],
119
- "rules": {
120
- "@typescript-eslint/no-explicit-any": "off",
121
- "@typescript-eslint/ban-types": "off",
122
- "@typescript-eslint/no-unused-vars": "off",
123
- "@typescript-eslint/explicit-module-boundary-types": "off"
124
- }
125
- }
126
- ],
127
- "plugins": [
128
- "mocha-no-only"
129
- ],
130
- "parserOptions": {
131
- "ecmaVersion": 2020
132
- },
133
- "env": {
134
- "node": true,
135
- "es6": true
136
- },
137
- "rules": {
138
- "comma-style": "error",
139
- "indent": [
140
- "error",
141
- 2,
142
- {
143
- "SwitchCase": 1,
144
- "VariableDeclarator": 2
145
- }
146
- ],
147
- "keyword-spacing": "error",
148
- "no-whitespace-before-property": "error",
149
- "no-buffer-constructor": "warn",
150
- "no-console": "off",
151
- "no-multi-spaces": "error",
152
- "no-constant-condition": "off",
153
- "func-call-spacing": "error",
154
- "no-trailing-spaces": "error",
155
- "no-undef": "error",
156
- "no-unneeded-ternary": "error",
157
- "no-const-assign": "error",
158
- "no-useless-rename": "error",
159
- "no-dupe-keys": "error",
160
- "space-in-parens": [
161
- "error",
162
- "never"
163
- ],
164
- "spaced-comment": [
165
- "error",
166
- "always",
167
- {
168
- "block": {
169
- "markers": [
170
- "!"
171
- ],
172
- "balanced": true
173
- }
174
- }
175
- ],
176
- "key-spacing": [
177
- "error",
178
- {
179
- "beforeColon": false,
180
- "afterColon": true
181
- }
182
- ],
183
- "comma-spacing": [
184
- "error",
185
- {
186
- "before": false,
187
- "after": true
188
- }
189
- ],
190
- "array-bracket-spacing": 1,
191
- "arrow-spacing": [
192
- "error",
193
- {
194
- "before": true,
195
- "after": true
196
- }
197
- ],
198
- "object-curly-spacing": [
199
- "error",
200
- "always"
201
- ],
202
- "comma-dangle": [
203
- "error",
204
- "never"
205
- ],
206
- "no-unreachable": "error",
207
- "quotes": [
208
- "error",
209
- "single"
210
- ],
211
- "quote-props": [
212
- "error",
213
- "as-needed"
214
- ],
215
- "semi": "error",
216
- "no-extra-semi": "error",
217
- "semi-spacing": "error",
218
- "no-spaced-func": "error",
219
- "no-throw-literal": "error",
220
- "space-before-blocks": "error",
221
- "space-before-function-paren": [
222
- "error",
223
- "never"
224
- ],
225
- "space-infix-ops": "error",
226
- "space-unary-ops": "error",
227
- "no-var": "warn",
228
- "prefer-const": "warn",
229
- "strict": [
230
- "error",
231
- "global"
232
- ],
233
- "no-restricted-globals": [
234
- "error",
235
- {
236
- "name": "context",
237
- "message": "Don't use Mocha's global context"
238
- }
239
- ],
240
- "no-prototype-builtins": "off",
241
- "mocha-no-only/mocha-no-only": [
242
- "error"
243
- ]
244
- }
245
- },
246
102
  "config": {
247
103
  "mongodbMemoryServer": {
248
104
  "disablePostinstall": true
@@ -251,5 +107,17 @@
251
107
  "funding": {
252
108
  "type": "opencollective",
253
109
  "url": "https://opencollective.com/mongoose"
110
+ },
111
+ "tsd": {
112
+ "directory": "test/types",
113
+ "compilerOptions": {
114
+ "esModuleInterop": false,
115
+ "strict": true,
116
+ "allowSyntheticDefaultImports": true,
117
+ "strictPropertyInitialization": false,
118
+ "noImplicitAny": false,
119
+ "module": "commonjs",
120
+ "target": "ES2017"
121
+ }
254
122
  }
255
123
  }
package/tools/repl.js CHANGED
@@ -11,7 +11,7 @@ async function run () {
11
11
  // Create new instance
12
12
  const replSet = new ReplSet({
13
13
  binary: {
14
- version: process.argv[3]
14
+ version: process.argv[2]
15
15
  },
16
16
  instanceOpts: [
17
17
  // Set the expiry job in MongoDB to run every second
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "paths": {
5
+ "mongoose" : ["./types/index.d.ts"]
6
+ }
7
+ },
8
+ "esModuleInterop": true,
9
+ "strictNullChecks": true
10
+ }