mongoose 6.2.1 → 6.2.4

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 (65) hide show
  1. package/.eslintrc.json +5 -1
  2. package/.lgtm.yml +3 -0
  3. package/CHANGELOG.md +54 -0
  4. package/dist/browser.umd.js +156 -152
  5. package/index.js +5 -1
  6. package/lib/aggregate.js +22 -27
  7. package/lib/browserDocument.js +1 -1
  8. package/lib/cast/number.js +2 -3
  9. package/lib/cast.js +7 -4
  10. package/lib/connection.js +43 -21
  11. package/lib/cursor/AggregationCursor.js +12 -7
  12. package/lib/cursor/QueryCursor.js +11 -6
  13. package/lib/document.js +58 -72
  14. package/lib/drivers/node-mongodb-native/collection.js +12 -4
  15. package/lib/drivers/node-mongodb-native/connection.js +11 -0
  16. package/lib/error/cast.js +3 -2
  17. package/lib/helpers/clone.js +11 -2
  18. package/lib/helpers/cursor/eachAsync.js +18 -15
  19. package/lib/helpers/document/cleanModifiedSubpaths.js +1 -0
  20. package/lib/helpers/document/compile.js +7 -4
  21. package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
  22. package/lib/helpers/indexes/getRelatedIndexes.js +59 -0
  23. package/lib/helpers/isAsyncFunction.js +6 -7
  24. package/lib/helpers/populate/assignVals.js +4 -0
  25. package/lib/helpers/printJestWarning.js +2 -2
  26. package/lib/helpers/projection/applyProjection.js +77 -0
  27. package/lib/helpers/projection/hasIncludedChildren.js +36 -0
  28. package/lib/helpers/projection/isExclusive.js +5 -2
  29. package/lib/helpers/projection/isInclusive.js +5 -1
  30. package/lib/helpers/query/cast$expr.js +14 -19
  31. package/lib/helpers/query/hasDollarKeys.js +7 -3
  32. package/lib/helpers/query/isOperator.js +5 -2
  33. package/lib/helpers/schema/getIndexes.js +6 -2
  34. package/lib/index.js +14 -17
  35. package/lib/internal.js +9 -1
  36. package/lib/model.js +159 -153
  37. package/lib/options/SchemaTypeOptions.js +1 -1
  38. package/lib/plugins/trackTransaction.js +1 -1
  39. package/lib/query.js +159 -147
  40. package/lib/queryhelpers.js +8 -28
  41. package/lib/schema/SubdocumentPath.js +5 -4
  42. package/lib/schema/array.js +13 -6
  43. package/lib/schema/buffer.js +1 -1
  44. package/lib/schema/date.js +1 -1
  45. package/lib/schema/decimal128.js +1 -1
  46. package/lib/schema/documentarray.js +9 -7
  47. package/lib/schema/number.js +1 -1
  48. package/lib/schema/objectid.js +1 -1
  49. package/lib/schema/string.js +4 -4
  50. package/lib/schema.js +12 -8
  51. package/lib/schematype.js +12 -14
  52. package/lib/types/ArraySubdocument.js +1 -1
  53. package/lib/types/DocumentArray/index.js +1 -1
  54. package/lib/types/array/index.js +2 -2
  55. package/lib/types/array/methods/index.js +10 -11
  56. package/lib/types/buffer.js +3 -3
  57. package/lib/types/map.js +3 -4
  58. package/lib/utils.js +9 -3
  59. package/package.json +17 -21
  60. package/tsconfig.json +0 -2
  61. package/types/Connection.d.ts +212 -0
  62. package/types/Error.d.ts +129 -0
  63. package/types/PipelineStage.d.ts +272 -0
  64. package/types/index.d.ts +61 -602
  65. package/lib/types/array/ArrayWrapper.js +0 -981
package/.eslintrc.json CHANGED
@@ -6,6 +6,7 @@
6
6
  "docs",
7
7
  "tools",
8
8
  "dist",
9
+ "website.js",
9
10
  "test/files/*",
10
11
  "benchmarks"
11
12
  ],
@@ -22,6 +23,8 @@
22
23
  "@typescript-eslint"
23
24
  ],
24
25
  "rules": {
26
+ "@typescript-eslint/triple-slash-reference": "off",
27
+ "spaced-comment": ["error", "always", { "markers": ["/"] }],
25
28
  "@typescript-eslint/no-explicit-any": "off",
26
29
  "@typescript-eslint/ban-types": "off",
27
30
  "@typescript-eslint/no-unused-vars": "off",
@@ -145,6 +148,7 @@
145
148
  "no-prototype-builtins": "off",
146
149
  "mocha-no-only/mocha-no-only": [
147
150
  "error"
148
- ]
151
+ ],
152
+ "no-empty": "off"
149
153
  }
150
154
  }
package/.lgtm.yml ADDED
@@ -0,0 +1,3 @@
1
+ path_classifiers:
2
+ test:
3
+ - lib
package/CHANGELOG.md CHANGED
@@ -1,3 +1,56 @@
1
+ 6.2.4 / 2022-02-28
2
+ ==================
3
+ * fix(query): correctly return full deleteOne(), deleteMany() result #11211
4
+ * fix(query): handle update validators on deeply nested subdocuments #11455 #11394
5
+ * fix(discriminator): handle modifying multiple nested paths underneath a discriminator #11428
6
+ * perf: improve isAsyncFunction #11408 [Uzlopak](https://github.com/Uzlopak)
7
+ * fix(index.d.ts): add typedefs for Schema `pick()` #11448 [Moisei-Shkil](https://github.com/Moisei-Shkil)
8
+ * fix(index.d.ts): allow type override for distinct() #11306
9
+ * fix(index.d.ts): allow array of validators in schema definition #11355
10
+ * fix(index.d.ts): improve connection typings #11418 [Uzlopak](https://github.com/Uzlopak)
11
+ * docs: add timestamps docs #11336
12
+ * docs(timestamps): explain how timestamps works under the hood #11336
13
+ * docs(migrating_to_6): add model.exists breaking change returning doument instead of boolean #11407 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
14
+ * docs(index.d.ts): add docs for FilterQuery, UpdateQuery, and LeanDocument #11457 [Moisei-Shkil](https://github.com/Moisei-Shkil)
15
+
16
+ 6.2.3 / 2022-02-21
17
+ ==================
18
+ * fix(model): avoid dropping base model indexes when using discriminators with `Connection.prototype.syncIndexes()` #11424 #11421 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
19
+ * fix(document): handle array defaults when selecting element underneath array #11376
20
+ * fix(populate): correctly handle depopulating populated subdocuments #11436
21
+ * fix(utils): improve deepEqual() handling for comparing objects with non-objects #11417
22
+ * fix(schema): allow declaring array of arrays using `[{ type: [String] }]` #11252
23
+ * perf: improve validation sync and async by replacing forEach with classic for loops #11414 [Uzlopak](https://github.com/Uzlopak)
24
+ * perf: make hasDollarKeys faster #11401 [Uzlopak](https://github.com/Uzlopak)
25
+ * fix(index.d.ts): ValidationError `errors` only contains CastError or ValidationError #11369 [Uzlopak](https://github.com/Uzlopak)
26
+ * fix(index.d.ts): make InsertManyResult.insertedIds return an array of Types.ObjectId by default #11197
27
+ * fix(index.d.ts): allow pre('save') middleware with pre options #11257
28
+ * fix(index.d.ts): add `supressReservedKeysWarning` option to schema #11439 [hiukky](https://github.com/hiukky)
29
+ * docs(connections): improve replica set hostname docs with correct error message and info about `err.reason.servers` #11200
30
+ * docs(populate): add virtual populate match option documentation #11411 [remirobichet](https://github.com/remirobichet)
31
+ * docs(document): add note to API docs that flattenMaps defaults to `true` for `toJSON()` but not `toObject()` #11213
32
+ * docs(document+model): add populate option to populate() API docs #11170
33
+ * docs(migrating_to_6): add additional info about removing omitUndefined #11038
34
+ * docs(migrating_to_6): add model.exists breaking change returning doument instead of boolean [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
35
+
36
+ 6.2.2 / 2022-02-16
37
+ ==================
38
+ * fix: fix QueryCursor and AggregationCursor compatibility with Node v17.5 #11381 [benjamingr](https://github.com/benjamingr)
39
+ * fix: better esm support, no necessity for setting allowSyntheticDefaultImports and esModuleInterop #11343 [Uzlopak](https://github.com/Uzlopak)
40
+ * fix(model): apply projection parameter to hydrate() #11375
41
+ * fix: fix issue with creating arrays of length > 10000 #11405 [Uzlopak](https://github.com/Uzlopak)
42
+ * fix(document): minimize single nested subdocs #11247
43
+ * fix(connection): handle reopening base connection with useDb() #11240
44
+ * perf: use property access instead of `get()` helper where possible #11389 [Uzlopak](https://github.com/Uzlopak)
45
+ * fix: use `isArray()` instead of `instanceof Array` #11393 [Uzlopak](https://github.com/Uzlopak)
46
+ * perf: improve performance of `cast$expr()` #11388 [Uzlopak](https://github.com/Uzlopak)
47
+ * perf: remove `startsWith()` from `isOperator()` #11400 [Uzlopak](https://github.com/Uzlopak)
48
+ * fix(index.d.ts): extract `PipelineStage` into separate file #11368 [Uzlopak](https://github.com/Uzlopak)
49
+ * fix(index.d.ts): fix $search highlight path option type #11373 [lmX2015](https://github.com/lmX2015)
50
+ * docs: update changelog file to CHANGELOG.md #11365 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
51
+ * docs: fix broken links #11388 #11377 [saibbyweb](https://github.com/saibbyweb)
52
+ * docs: remove double determiners in connections docs #11340 [Erma32](https://github.com/Erma32)
53
+
1
54
  6.2.1 / 2022-02-07
2
55
  ==================
3
56
  * perf: improve performance especially of validate and clone #11298 [Uzlopak](https://github.com/Uzlopak)
@@ -21,6 +74,7 @@
21
74
 
22
75
  6.2.0 / 2022-02-02
23
76
  ==================
77
+ * feat: upgrade MongoDB driver to 4.3.1
24
78
  * feat(connection+mongoose): add support for continueOnError for syncIndexes #11266 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
25
79
  * feat(query): cast literals in `$expr` where possible #10663
26
80
  * feat(schema+mongoose): add pluginTags to allow applying global plugins to only schemas with matching tags #9780