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/.eslintrc.json ADDED
@@ -0,0 +1,150 @@
1
+ {
2
+ "extends": [
3
+ "eslint:recommended"
4
+ ],
5
+ "ignorePatterns": [
6
+ "docs",
7
+ "tools",
8
+ "dist",
9
+ "test/files/*",
10
+ "benchmarks"
11
+ ],
12
+ "overrides": [
13
+ {
14
+ "files": [
15
+ "**/*.{ts,tsx}"
16
+ ],
17
+ "extends": [
18
+ "plugin:@typescript-eslint/eslint-recommended",
19
+ "plugin:@typescript-eslint/recommended"
20
+ ],
21
+ "plugins": [
22
+ "@typescript-eslint"
23
+ ],
24
+ "rules": {
25
+ "@typescript-eslint/no-explicit-any": "off",
26
+ "@typescript-eslint/ban-types": "off",
27
+ "@typescript-eslint/no-unused-vars": "off",
28
+ "@typescript-eslint/explicit-module-boundary-types": "off"
29
+ }
30
+ }
31
+ ],
32
+ "plugins": [
33
+ "mocha-no-only"
34
+ ],
35
+ "parserOptions": {
36
+ "ecmaVersion": 2020
37
+ },
38
+ "env": {
39
+ "node": true,
40
+ "es6": true
41
+ },
42
+ "rules": {
43
+ "comma-style": "error",
44
+ "indent": [
45
+ "error",
46
+ 2,
47
+ {
48
+ "SwitchCase": 1,
49
+ "VariableDeclarator": 2
50
+ }
51
+ ],
52
+ "keyword-spacing": "error",
53
+ "no-whitespace-before-property": "error",
54
+ "no-buffer-constructor": "warn",
55
+ "no-console": "off",
56
+ "no-constant-condition": "off",
57
+ "no-multi-spaces": "error",
58
+ "func-call-spacing": "error",
59
+ "no-trailing-spaces": "error",
60
+ "no-undef": "error",
61
+ "no-unneeded-ternary": "error",
62
+ "no-const-assign": "error",
63
+ "no-useless-rename": "error",
64
+ "no-dupe-keys": "error",
65
+ "space-in-parens": [
66
+ "error",
67
+ "never"
68
+ ],
69
+ "spaced-comment": [
70
+ "error",
71
+ "always",
72
+ {
73
+ "block": {
74
+ "markers": [
75
+ "!"
76
+ ],
77
+ "balanced": true
78
+ }
79
+ }
80
+ ],
81
+ "key-spacing": [
82
+ "error",
83
+ {
84
+ "beforeColon": false,
85
+ "afterColon": true
86
+ }
87
+ ],
88
+ "comma-spacing": [
89
+ "error",
90
+ {
91
+ "before": false,
92
+ "after": true
93
+ }
94
+ ],
95
+ "array-bracket-spacing": 1,
96
+ "arrow-spacing": [
97
+ "error",
98
+ {
99
+ "before": true,
100
+ "after": true
101
+ }
102
+ ],
103
+ "object-curly-spacing": [
104
+ "error",
105
+ "always"
106
+ ],
107
+ "comma-dangle": [
108
+ "error",
109
+ "never"
110
+ ],
111
+ "no-unreachable": "error",
112
+ "quotes": [
113
+ "error",
114
+ "single"
115
+ ],
116
+ "quote-props": [
117
+ "error",
118
+ "as-needed"
119
+ ],
120
+ "semi": "error",
121
+ "no-extra-semi": "error",
122
+ "semi-spacing": "error",
123
+ "no-spaced-func": "error",
124
+ "no-throw-literal": "error",
125
+ "space-before-blocks": "error",
126
+ "space-before-function-paren": [
127
+ "error",
128
+ "never"
129
+ ],
130
+ "space-infix-ops": "error",
131
+ "space-unary-ops": "error",
132
+ "no-var": "warn",
133
+ "prefer-const": "warn",
134
+ "strict": [
135
+ "error",
136
+ "global"
137
+ ],
138
+ "no-restricted-globals": [
139
+ "error",
140
+ {
141
+ "name": "context",
142
+ "message": "Don't use Mocha's global context"
143
+ }
144
+ ],
145
+ "no-prototype-builtins": "off",
146
+ "mocha-no-only/mocha-no-only": [
147
+ "error"
148
+ ]
149
+ }
150
+ }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,53 @@
1
+ 6.2.1 / 2022-02-07
2
+ ==================
3
+ * perf: improve performance especially of validate and clone #11298 [Uzlopak](https://github.com/Uzlopak)
4
+ * perf: remove regexp-clone #11327 [Uzlopak](https://github.com/Uzlopak)
5
+ * fix(document): handle initing nested properties in non-strict documents #11309
6
+ * fix(query): cast $elemMatch underneath $all #11314
7
+ * fix(populate): respect schema-level strictPopulate option #11290
8
+ * fix: set default for dotted path projection #11293 [noseworthy](https://github.com/noseworthy)
9
+ * fix(model): correctly handle writeConcern.w = 0 when saving #11300
10
+ * fix(model): throw VersionError when saving with no changes and optimisticConcurrency = true #11295
11
+ * fix(query): avoid adding $each to $addToSet on mixed arrays #11284
12
+ * fix(index.d.ts): allow using type: [Schema.Types.ObjectId] for ObjectId arrays #11194
13
+ * fix(index.d.ts): make Types.DocumentArray<> convert type to subdoc, rename TMethods -> TMethodsAndOverrides #11061
14
+ * fix(index.d.ts): support passing generic to createCollection() and `collection()` for integration with MongoDB Node driver's collection class #11131
15
+ * fix(index.d.ts): add strictPopulate to MongooseOptions #11276
16
+ * docs: mark Mongoose 6 as compatible with MongoDB 4 #11320 [JavaScriptBach](https://github.com/JavaScriptBach)
17
+ * docs: remove documentation for useNestedStrict #11313 [mark-langer](https://github.com/mark-langer)
18
+ * docs: add "new" to ObjectId class in aggregate.js docs #11322 [JavanPoirier](https://github.com/JavanPoirier)
19
+ * chore: handle eslint configuration in .eslintrc.json #11326 [Uzlopak](https://github.com/Uzlopak)
20
+ * refactor: add parenthesis for constructors in tests #11330 [apeltop](https://github.com/apeltop)
21
+
22
+ 6.2.0 / 2022-02-02
23
+ ==================
24
+ * feat(connection+mongoose): add support for continueOnError for syncIndexes #11266 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
25
+ * feat(query): cast literals in `$expr` where possible #10663
26
+ * feat(schema+mongoose): add pluginTags to allow applying global plugins to only schemas with matching tags #9780
27
+ * feat(discriminator): support overwriteModels:true to reuse discriminator names #11244 #10931 [IslandRhythms](https://github.com/IslandRhythms)
28
+ * feat(index.d.ts): add DocType generic param to Model functions that return queries to better support projections #11156
29
+ * feat(error): export MongooseServerSelectionError #11202
30
+ * feat(schematype): add validators, path, isRequired to public API and TypeScript types #11139
31
+ * fix(model): make exists(...) return lean document with _id or null instead of boolean #11142 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
32
+ * fix(model): support storing versionKey in nested paths #10980
33
+ * fix(index.d.ts): add options to `bulkSave()` type def #11201 [Uzlopak](https://github.com/Uzlopak)
34
+ * fix(index.d.ts): better support for query projections #11210 [EugeneKorshenko](https://github.com/EugeneKorshenko)
35
+
36
+ 6.1.10 / 2022-02-01
37
+ ===================
38
+ * fix(mongoose): correctly handle destructured isValidObjectId #11304
39
+ * fix(mongoose): defer to MongoDB driver isValid() for `isValidObjectId()` #11227
40
+
41
+ 6.1.9 / 2022-01-31
42
+ ==================
43
+ * fix(query): respect nested schema strict as default when casting query filters #11291
44
+ * fix(mongoose): make isValidObjectId() consistent with isValid(), make `ObjectId()` casting more flexible #11209
45
+ * fix(setDefaultsOnInsert): ignore defaults underneath maps #11235
46
+ * fix(query): avoid setting nested schema properties that are stripped out by strictQuery to undefined in query filter #11291
47
+ * fix: check for all flags in a regex deepequal #11242 [Uzlopak](https://github.com/Uzlopak)
48
+ * fix: replace substr with substring #11278 [Uzlopak](https://github.com/Uzlopak)
49
+ * docs: port for documentation testing in CONTRIBUTING.md #11273 [Uzlopak](https://github.com/Uzlopak)
50
+
1
51
  6.1.8 / 2022-01-24
2
52
  ==================
3
53
  * fix(connection): stop leaking sessions in .transaction() #11259 #11256 [Uzlopak](https://github.com/Uzlopak)