mongoose 6.1.9 → 6.2.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.
- package/.eslintrc.json +154 -0
- package/CHANGELOG.md +59 -0
- package/dist/browser.umd.js +233 -222
- package/index.js +5 -1
- package/lib/aggregate.js +23 -28
- package/lib/browserDocument.js +1 -1
- package/lib/cast/number.js +2 -3
- package/lib/cast.js +9 -7
- package/lib/connection.js +76 -24
- package/lib/cursor/AggregationCursor.js +12 -7
- package/lib/cursor/QueryCursor.js +11 -6
- package/lib/document.js +107 -107
- package/lib/drivers/node-mongodb-native/collection.js +12 -4
- package/lib/drivers/node-mongodb-native/connection.js +11 -0
- package/lib/error/cast.js +3 -2
- package/lib/error/index.js +11 -0
- package/lib/error/syncIndexes.js +30 -0
- package/lib/helpers/clone.js +51 -29
- package/lib/helpers/common.js +2 -2
- package/lib/helpers/cursor/eachAsync.js +18 -15
- package/lib/helpers/document/compile.js +7 -4
- package/lib/helpers/getFunctionName.js +6 -4
- package/lib/helpers/isMongooseObject.js +9 -8
- package/lib/helpers/isObject.js +4 -4
- package/lib/helpers/model/discriminator.js +2 -1
- package/lib/helpers/path/parentPaths.js +10 -5
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -2
- package/lib/helpers/populate/assignVals.js +8 -4
- package/lib/helpers/populate/getModelsMapForPopulate.js +4 -4
- package/lib/helpers/populate/markArraySubdocsPopulated.js +3 -1
- package/lib/helpers/populate/modelNamesFromRefPath.js +4 -3
- package/lib/helpers/printJestWarning.js +2 -2
- package/lib/helpers/projection/applyProjection.js +77 -0
- package/lib/helpers/projection/hasIncludedChildren.js +36 -0
- package/lib/helpers/projection/isExclusive.js +5 -2
- package/lib/helpers/projection/isInclusive.js +5 -1
- package/lib/helpers/query/cast$expr.js +279 -0
- package/lib/helpers/query/castUpdate.js +6 -2
- package/lib/helpers/query/isOperator.js +5 -2
- package/lib/helpers/schema/applyPlugins.js +11 -0
- package/lib/helpers/schema/getPath.js +4 -2
- package/lib/helpers/timestamps/setupTimestamps.js +3 -8
- package/lib/index.js +28 -26
- package/lib/internal.js +1 -1
- package/lib/model.js +161 -122
- package/lib/options/SchemaTypeOptions.js +1 -1
- package/lib/plugins/trackTransaction.js +5 -4
- package/lib/query.js +159 -146
- package/lib/queryhelpers.js +10 -10
- package/lib/schema/SubdocumentPath.js +4 -3
- package/lib/schema/array.js +30 -21
- package/lib/schema/buffer.js +1 -1
- package/lib/schema/date.js +1 -1
- package/lib/schema/decimal128.js +1 -1
- package/lib/schema/documentarray.js +9 -11
- package/lib/schema/number.js +1 -1
- package/lib/schema/objectid.js +2 -2
- package/lib/schema/string.js +4 -4
- package/lib/schema.js +9 -8
- package/lib/schematype.js +77 -30
- package/lib/types/ArraySubdocument.js +2 -1
- package/lib/types/DocumentArray/index.js +10 -27
- package/lib/types/DocumentArray/isMongooseDocumentArray.js +5 -0
- package/lib/types/DocumentArray/methods/index.js +15 -3
- package/lib/types/array/index.js +22 -21
- package/lib/types/array/isMongooseArray.js +5 -0
- package/lib/types/array/methods/index.js +22 -23
- package/lib/types/buffer.js +3 -3
- package/lib/types/map.js +2 -3
- package/lib/utils.js +10 -7
- package/package.json +19 -151
- package/tools/repl.js +1 -1
- package/tsconfig.json +8 -0
- package/types/PipelineStage.d.ts +272 -0
- package/{index.d.ts → types/index.d.ts} +156 -357
- package/lib/types/array/ArrayWrapper.js +0 -981
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"eslint:recommended"
|
|
4
|
+
],
|
|
5
|
+
"ignorePatterns": [
|
|
6
|
+
"docs",
|
|
7
|
+
"tools",
|
|
8
|
+
"dist",
|
|
9
|
+
"website.js",
|
|
10
|
+
"test/files/*",
|
|
11
|
+
"benchmarks"
|
|
12
|
+
],
|
|
13
|
+
"overrides": [
|
|
14
|
+
{
|
|
15
|
+
"files": [
|
|
16
|
+
"**/*.{ts,tsx}"
|
|
17
|
+
],
|
|
18
|
+
"extends": [
|
|
19
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
20
|
+
"plugin:@typescript-eslint/recommended"
|
|
21
|
+
],
|
|
22
|
+
"plugins": [
|
|
23
|
+
"@typescript-eslint"
|
|
24
|
+
],
|
|
25
|
+
"rules": {
|
|
26
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
27
|
+
"spaced-comment": ["error", "always", { "markers": ["/"] }],
|
|
28
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
29
|
+
"@typescript-eslint/ban-types": "off",
|
|
30
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
31
|
+
"@typescript-eslint/explicit-module-boundary-types": "off"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"plugins": [
|
|
36
|
+
"mocha-no-only"
|
|
37
|
+
],
|
|
38
|
+
"parserOptions": {
|
|
39
|
+
"ecmaVersion": 2020
|
|
40
|
+
},
|
|
41
|
+
"env": {
|
|
42
|
+
"node": true,
|
|
43
|
+
"es6": true
|
|
44
|
+
},
|
|
45
|
+
"rules": {
|
|
46
|
+
"comma-style": "error",
|
|
47
|
+
"indent": [
|
|
48
|
+
"error",
|
|
49
|
+
2,
|
|
50
|
+
{
|
|
51
|
+
"SwitchCase": 1,
|
|
52
|
+
"VariableDeclarator": 2
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"keyword-spacing": "error",
|
|
56
|
+
"no-whitespace-before-property": "error",
|
|
57
|
+
"no-buffer-constructor": "warn",
|
|
58
|
+
"no-console": "off",
|
|
59
|
+
"no-constant-condition": "off",
|
|
60
|
+
"no-multi-spaces": "error",
|
|
61
|
+
"func-call-spacing": "error",
|
|
62
|
+
"no-trailing-spaces": "error",
|
|
63
|
+
"no-undef": "error",
|
|
64
|
+
"no-unneeded-ternary": "error",
|
|
65
|
+
"no-const-assign": "error",
|
|
66
|
+
"no-useless-rename": "error",
|
|
67
|
+
"no-dupe-keys": "error",
|
|
68
|
+
"space-in-parens": [
|
|
69
|
+
"error",
|
|
70
|
+
"never"
|
|
71
|
+
],
|
|
72
|
+
"spaced-comment": [
|
|
73
|
+
"error",
|
|
74
|
+
"always",
|
|
75
|
+
{
|
|
76
|
+
"block": {
|
|
77
|
+
"markers": [
|
|
78
|
+
"!"
|
|
79
|
+
],
|
|
80
|
+
"balanced": true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"key-spacing": [
|
|
85
|
+
"error",
|
|
86
|
+
{
|
|
87
|
+
"beforeColon": false,
|
|
88
|
+
"afterColon": true
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"comma-spacing": [
|
|
92
|
+
"error",
|
|
93
|
+
{
|
|
94
|
+
"before": false,
|
|
95
|
+
"after": true
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"array-bracket-spacing": 1,
|
|
99
|
+
"arrow-spacing": [
|
|
100
|
+
"error",
|
|
101
|
+
{
|
|
102
|
+
"before": true,
|
|
103
|
+
"after": true
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"object-curly-spacing": [
|
|
107
|
+
"error",
|
|
108
|
+
"always"
|
|
109
|
+
],
|
|
110
|
+
"comma-dangle": [
|
|
111
|
+
"error",
|
|
112
|
+
"never"
|
|
113
|
+
],
|
|
114
|
+
"no-unreachable": "error",
|
|
115
|
+
"quotes": [
|
|
116
|
+
"error",
|
|
117
|
+
"single"
|
|
118
|
+
],
|
|
119
|
+
"quote-props": [
|
|
120
|
+
"error",
|
|
121
|
+
"as-needed"
|
|
122
|
+
],
|
|
123
|
+
"semi": "error",
|
|
124
|
+
"no-extra-semi": "error",
|
|
125
|
+
"semi-spacing": "error",
|
|
126
|
+
"no-spaced-func": "error",
|
|
127
|
+
"no-throw-literal": "error",
|
|
128
|
+
"space-before-blocks": "error",
|
|
129
|
+
"space-before-function-paren": [
|
|
130
|
+
"error",
|
|
131
|
+
"never"
|
|
132
|
+
],
|
|
133
|
+
"space-infix-ops": "error",
|
|
134
|
+
"space-unary-ops": "error",
|
|
135
|
+
"no-var": "warn",
|
|
136
|
+
"prefer-const": "warn",
|
|
137
|
+
"strict": [
|
|
138
|
+
"error",
|
|
139
|
+
"global"
|
|
140
|
+
],
|
|
141
|
+
"no-restricted-globals": [
|
|
142
|
+
"error",
|
|
143
|
+
{
|
|
144
|
+
"name": "context",
|
|
145
|
+
"message": "Don't use Mocha's global context"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"no-prototype-builtins": "off",
|
|
149
|
+
"mocha-no-only/mocha-no-only": [
|
|
150
|
+
"error"
|
|
151
|
+
],
|
|
152
|
+
"no-empty": "off"
|
|
153
|
+
}
|
|
154
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
+
6.2.2 / 2022-02-16
|
|
2
|
+
==================
|
|
3
|
+
* fix: fix QueryCursor and AggregationCursor compatibility with Node v17.5 #11381 [benjamingr](https://github.com/benjamingr)
|
|
4
|
+
* fix: better esm support, no necessity for setting allowSyntheticDefaultImports and esModuleInterop #11343 [Uzlopak](https://github.com/Uzlopak)
|
|
5
|
+
* fix(model): apply projection parameter to hydrate() #11375
|
|
6
|
+
* fix: fix issue with creating arrays of length > 10000 #11405 [Uzlopak](https://github.com/Uzlopak)
|
|
7
|
+
* fix(document): minimize single nested subdocs #11247
|
|
8
|
+
* fix(connection): handle reopening base connection with useDb() #11240
|
|
9
|
+
* perf: use property access instead of `get()` helper where possible #11389 [Uzlopak](https://github.com/Uzlopak)
|
|
10
|
+
* fix: use `isArray()` instead of `instanceof Array` #11393 [Uzlopak](https://github.com/Uzlopak)
|
|
11
|
+
* perf: improve performance of `cast$expr()` #11388 [Uzlopak](https://github.com/Uzlopak)
|
|
12
|
+
* perf: remove `startsWith()` from `isOperator()` #11400 [Uzlopak](https://github.com/Uzlopak)
|
|
13
|
+
* fix(index.d.ts): extract `PipelineStage` into separate file #11368 [Uzlopak](https://github.com/Uzlopak)
|
|
14
|
+
* fix(index.d.ts): fix $search highlight path option type #11373 [lmX2015](https://github.com/lmX2015)
|
|
15
|
+
* docs: update changelog file to CHANGELOG.md #11365 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
|
|
16
|
+
* docs: fix broken links #11388 #11377 [saibbyweb](https://github.com/saibbyweb)
|
|
17
|
+
* docs: remove double determiners in connections docs #11340 [Erma32](https://github.com/Erma32)
|
|
18
|
+
|
|
19
|
+
6.2.1 / 2022-02-07
|
|
20
|
+
==================
|
|
21
|
+
* perf: improve performance especially of validate and clone #11298 [Uzlopak](https://github.com/Uzlopak)
|
|
22
|
+
* perf: remove regexp-clone #11327 [Uzlopak](https://github.com/Uzlopak)
|
|
23
|
+
* fix(document): handle initing nested properties in non-strict documents #11309
|
|
24
|
+
* fix(query): cast $elemMatch underneath $all #11314
|
|
25
|
+
* fix(populate): respect schema-level strictPopulate option #11290
|
|
26
|
+
* fix: set default for dotted path projection #11293 [noseworthy](https://github.com/noseworthy)
|
|
27
|
+
* fix(model): correctly handle writeConcern.w = 0 when saving #11300
|
|
28
|
+
* fix(model): throw VersionError when saving with no changes and optimisticConcurrency = true #11295
|
|
29
|
+
* fix(query): avoid adding $each to $addToSet on mixed arrays #11284
|
|
30
|
+
* fix(index.d.ts): allow using type: [Schema.Types.ObjectId] for ObjectId arrays #11194
|
|
31
|
+
* fix(index.d.ts): make Types.DocumentArray<> convert type to subdoc, rename TMethods -> TMethodsAndOverrides #11061
|
|
32
|
+
* fix(index.d.ts): support passing generic to createCollection() and `collection()` for integration with MongoDB Node driver's collection class #11131
|
|
33
|
+
* fix(index.d.ts): add strictPopulate to MongooseOptions #11276
|
|
34
|
+
* docs: mark Mongoose 6 as compatible with MongoDB 4 #11320 [JavaScriptBach](https://github.com/JavaScriptBach)
|
|
35
|
+
* docs: remove documentation for useNestedStrict #11313 [mark-langer](https://github.com/mark-langer)
|
|
36
|
+
* docs: add "new" to ObjectId class in aggregate.js docs #11322 [JavanPoirier](https://github.com/JavanPoirier)
|
|
37
|
+
* chore: handle eslint configuration in .eslintrc.json #11326 [Uzlopak](https://github.com/Uzlopak)
|
|
38
|
+
* refactor: add parenthesis for constructors in tests #11330 [apeltop](https://github.com/apeltop)
|
|
39
|
+
|
|
40
|
+
6.2.0 / 2022-02-02
|
|
41
|
+
==================
|
|
42
|
+
* feat: upgrade MongoDB driver to 4.3.1
|
|
43
|
+
* feat(connection+mongoose): add support for continueOnError for syncIndexes #11266 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
|
|
44
|
+
* feat(query): cast literals in `$expr` where possible #10663
|
|
45
|
+
* feat(schema+mongoose): add pluginTags to allow applying global plugins to only schemas with matching tags #9780
|
|
46
|
+
* feat(discriminator): support overwriteModels:true to reuse discriminator names #11244 #10931 [IslandRhythms](https://github.com/IslandRhythms)
|
|
47
|
+
* feat(index.d.ts): add DocType generic param to Model functions that return queries to better support projections #11156
|
|
48
|
+
* feat(error): export MongooseServerSelectionError #11202
|
|
49
|
+
* feat(schematype): add validators, path, isRequired to public API and TypeScript types #11139
|
|
50
|
+
* fix(model): make exists(...) return lean document with _id or null instead of boolean #11142 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
|
|
51
|
+
* fix(model): support storing versionKey in nested paths #10980
|
|
52
|
+
* fix(index.d.ts): add options to `bulkSave()` type def #11201 [Uzlopak](https://github.com/Uzlopak)
|
|
53
|
+
* fix(index.d.ts): better support for query projections #11210 [EugeneKorshenko](https://github.com/EugeneKorshenko)
|
|
54
|
+
|
|
55
|
+
6.1.10 / 2022-02-01
|
|
56
|
+
===================
|
|
57
|
+
* fix(mongoose): correctly handle destructured isValidObjectId #11304
|
|
58
|
+
* fix(mongoose): defer to MongoDB driver isValid() for `isValidObjectId()` #11227
|
|
59
|
+
|
|
1
60
|
6.1.9 / 2022-01-31
|
|
2
61
|
==================
|
|
3
62
|
* fix(query): respect nested schema strict as default when casting query filters #11291
|