mongoose 6.3.1 → 6.3.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.
- package/CHANGELOG.md +7300 -0
- package/History.md +1 -0
- package/README.md +2 -2
- package/dist/browser.umd.js +1 -1
- package/lib/connection.js +2 -1
- package/lib/document.js +59 -59
- package/lib/error/cast.js +2 -1
- package/lib/helpers/clone.js +2 -1
- package/lib/helpers/common.js +0 -8
- package/lib/helpers/immediate.js +3 -1
- package/lib/helpers/isAsyncFunction.js +19 -7
- package/lib/helpers/model/castBulkWrite.js +12 -0
- package/lib/helpers/query/cast$expr.js +4 -1
- package/lib/index.js +1 -1
- package/lib/internal.js +0 -1
- package/lib/model.js +49 -59
- package/lib/query.js +7 -3
- package/lib/queryhelpers.js +3 -2
- package/lib/schema/SubdocumentPath.js +3 -15
- package/lib/schema/documentarray.js +5 -3
- package/lib/schema/number.js +1 -5
- package/lib/schema/objectid.js +2 -4
- package/lib/schema/string.js +3 -6
- package/lib/schema.js +9 -0
- package/lib/types/DocumentArray/methods/index.js +8 -0
- package/lib/utils.js +4 -0
- package/package.json +39 -19
- package/tsconfig.json +1 -2
- package/types/aggregate.d.ts +1 -2
- package/types/connection.d.ts +3 -4
- package/types/cursor.d.ts +3 -2
- package/types/document.d.ts +15 -12
- package/types/error.d.ts +124 -124
- package/types/index.d.ts +173 -147
- package/types/mongooseoptions.d.ts +1 -2
- package/types/schemaoptions.d.ts +1 -2
|
@@ -113,10 +113,12 @@ function _createConstructor(schema, options, baseClass) {
|
|
|
113
113
|
Subdocument || (Subdocument = require('../types/ArraySubdocument'));
|
|
114
114
|
|
|
115
115
|
// compile an embedded document for this schema
|
|
116
|
-
function EmbeddedDocument() {
|
|
116
|
+
function EmbeddedDocument(_value, parentArray) {
|
|
117
117
|
Subdocument.apply(this, arguments);
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
if (parentArray == null || parentArray.getArrayParent() == null) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.$session(parentArray.getArrayParent().$session());
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
schema._preCompile();
|
package/lib/schema/number.js
CHANGED
|
@@ -353,11 +353,7 @@ SchemaNumber.prototype.enum = function(values, message) {
|
|
|
353
353
|
*/
|
|
354
354
|
|
|
355
355
|
SchemaNumber.prototype.cast = function(value, doc, init) {
|
|
356
|
-
if (SchemaType._isRef(this, value, doc, init)) {
|
|
357
|
-
if (typeof value === 'number') {
|
|
358
|
-
return value;
|
|
359
|
-
}
|
|
360
|
-
|
|
356
|
+
if (typeof value !== 'number' && SchemaType._isRef(this, value, doc, init)) {
|
|
361
357
|
if (value == null || utils.isNonBuiltinObject(value)) {
|
|
362
358
|
return this._castRef(value, doc, init);
|
|
363
359
|
}
|
package/lib/schema/objectid.js
CHANGED
|
@@ -221,11 +221,9 @@ ObjectId.prototype.checkRequired = function checkRequired(value, doc) {
|
|
|
221
221
|
*/
|
|
222
222
|
|
|
223
223
|
ObjectId.prototype.cast = function(value, doc, init) {
|
|
224
|
-
if (SchemaType._isRef(this, value, doc, init)) {
|
|
224
|
+
if (!(value instanceof oid) && SchemaType._isRef(this, value, doc, init)) {
|
|
225
225
|
// wait! we may need to cast this to a document
|
|
226
|
-
if (value
|
|
227
|
-
return value;
|
|
228
|
-
} else if ((getConstructorName(value) || '').toLowerCase() === 'objectid') {
|
|
226
|
+
if ((getConstructorName(value) || '').toLowerCase() === 'objectid') {
|
|
229
227
|
return new oid(value.toHexString());
|
|
230
228
|
}
|
|
231
229
|
|
package/lib/schema/string.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Module dependencies.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const { BSONRegExp } = require('bson');
|
|
7
8
|
const SchemaType = require('../schematype');
|
|
8
9
|
const MongooseError = require('../error/index');
|
|
9
10
|
const SchemaStringOptions = require('../options/SchemaStringOptions');
|
|
@@ -580,11 +581,7 @@ SchemaString.prototype.checkRequired = function checkRequired(value, doc) {
|
|
|
580
581
|
*/
|
|
581
582
|
|
|
582
583
|
SchemaString.prototype.cast = function(value, doc, init) {
|
|
583
|
-
if (SchemaType._isRef(this, value, doc, init)) {
|
|
584
|
-
if (typeof value === 'string') {
|
|
585
|
-
return value;
|
|
586
|
-
}
|
|
587
|
-
|
|
584
|
+
if (typeof value !== 'string' && SchemaType._isRef(this, value, doc, init)) {
|
|
588
585
|
return this._castRef(value, doc, init);
|
|
589
586
|
}
|
|
590
587
|
|
|
@@ -680,7 +677,7 @@ SchemaString.prototype.castForQuery = function($conditional, val) {
|
|
|
680
677
|
return handler.call(this, val);
|
|
681
678
|
}
|
|
682
679
|
val = $conditional;
|
|
683
|
-
if (Object.prototype.toString.call(val) === '[object RegExp]') {
|
|
680
|
+
if (Object.prototype.toString.call(val) === '[object RegExp]' || val instanceof BSONRegExp) {
|
|
684
681
|
return val;
|
|
685
682
|
}
|
|
686
683
|
|
package/lib/schema.js
CHANGED
|
@@ -1235,6 +1235,15 @@ function createMapNestedSchemaType(schema, schemaType, path, obj, options) {
|
|
|
1235
1235
|
_mapType = { [schema.options.typeKey]: obj.of };
|
|
1236
1236
|
}
|
|
1237
1237
|
|
|
1238
|
+
if (_mapType[schema.options.typeKey] && _mapType[schema.options.typeKey].instanceOfSchema) {
|
|
1239
|
+
const subdocumentSchema = _mapType[schema.options.typeKey];
|
|
1240
|
+
subdocumentSchema.eachPath((subpath, type) => {
|
|
1241
|
+
if (type.options.select === true || type.options.select === false) {
|
|
1242
|
+
throw new MongooseError('Cannot use schema-level projections (`select: true` or `select: false`) within maps at path "' + path + '.' + subpath + '"');
|
|
1243
|
+
}
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1238
1247
|
if (utils.hasUserDefinedProperty(obj, 'ref')) {
|
|
1239
1248
|
_mapType.ref = obj.ref;
|
|
1240
1249
|
}
|
package/lib/utils.js
CHANGED
|
@@ -516,6 +516,10 @@ exports.populate = function populate(path, select, model, match, options, subPop
|
|
|
516
516
|
let obj = null;
|
|
517
517
|
if (arguments.length === 1) {
|
|
518
518
|
if (path instanceof PopulateOptions) {
|
|
519
|
+
// If reusing old populate docs, avoid reusing `_docs` because that may
|
|
520
|
+
// lead to bugs and memory leaks. See gh-11641
|
|
521
|
+
path._docs = [];
|
|
522
|
+
path._childDocs = [];
|
|
519
523
|
return [path];
|
|
520
524
|
}
|
|
521
525
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "6.3.
|
|
4
|
+
"version": "6.3.4",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -22,51 +22,69 @@
|
|
|
22
22
|
"bson": "^4.6.2",
|
|
23
23
|
"kareem": "2.3.5",
|
|
24
24
|
"mongodb": "4.5.0",
|
|
25
|
-
"mpath": "0.
|
|
26
|
-
"mquery": "4.0.
|
|
25
|
+
"mpath": "0.9.0",
|
|
26
|
+
"mquery": "4.0.3",
|
|
27
27
|
"ms": "2.1.3",
|
|
28
28
|
"sift": "16.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@babel/core": "7.17.
|
|
32
|
-
"@babel/preset-env": "7.
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
34
|
-
"@typescript-eslint/parser": "5.
|
|
31
|
+
"@babel/core": "7.17.10",
|
|
32
|
+
"@babel/preset-env": "7.17.10",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "5.21.0",
|
|
34
|
+
"@typescript-eslint/parser": "5.21.0",
|
|
35
35
|
"acquit": "1.2.1",
|
|
36
36
|
"acquit-ignore": "0.2.0",
|
|
37
37
|
"acquit-require": "0.1.1",
|
|
38
|
-
"assert-browserify": "
|
|
39
|
-
"axios": "0.
|
|
40
|
-
"babel-loader": "8.2.
|
|
38
|
+
"assert-browserify": "2.0.0",
|
|
39
|
+
"axios": "0.27.2",
|
|
40
|
+
"babel-loader": "8.2.5",
|
|
41
41
|
"benchmark": "2.1.4",
|
|
42
42
|
"bluebird": "3.7.2",
|
|
43
|
+
"buffer": "^5.6.0",
|
|
43
44
|
"cheerio": "1.0.0-rc.10",
|
|
44
45
|
"crypto-browserify": "3.12.0",
|
|
45
46
|
"dox": "0.3.1",
|
|
46
|
-
"eslint": "8.
|
|
47
|
+
"eslint": "8.14.0",
|
|
47
48
|
"eslint-plugin-mocha-no-only": "1.1.1",
|
|
48
|
-
"highlight.js": "11.5.
|
|
49
|
+
"highlight.js": "11.5.1",
|
|
49
50
|
"lodash.isequal": "4.5.0",
|
|
50
51
|
"lodash.isequalwith": "4.4.0",
|
|
51
|
-
"marked": "4.0.
|
|
52
|
-
"
|
|
52
|
+
"marked": "4.0.14",
|
|
53
|
+
"mkdirp": "^1.0.4",
|
|
54
|
+
"mocha": "10.0.0",
|
|
53
55
|
"moment": "2.x",
|
|
54
|
-
"mongodb-memory-server": "8.
|
|
56
|
+
"mongodb-memory-server": "8.5.2",
|
|
57
|
+
"ncp": "^2.0.0",
|
|
55
58
|
"nyc": "15.1.0",
|
|
56
59
|
"pug": "3.0.2",
|
|
57
60
|
"q": "1.5.1",
|
|
58
61
|
"serve-handler": "6.1.3",
|
|
59
|
-
"sinon": "13.0.
|
|
62
|
+
"sinon": "13.0.2",
|
|
60
63
|
"stream-browserify": "3.0.0",
|
|
61
|
-
"tsd": "0.
|
|
62
|
-
"typescript": "4.6.
|
|
64
|
+
"tsd": "0.20.0",
|
|
65
|
+
"typescript": "4.6.4",
|
|
63
66
|
"uuid": "8.3.2",
|
|
64
|
-
"webpack": "5.
|
|
67
|
+
"webpack": "5.72.0"
|
|
65
68
|
},
|
|
66
69
|
"directories": {
|
|
67
70
|
"lib": "./lib/mongoose"
|
|
68
71
|
},
|
|
69
72
|
"scripts": {
|
|
73
|
+
"docs:clean": "npm run docs:clean:stable",
|
|
74
|
+
"docs:clean:stable": "rimraf index.html && rimraf -rf ./docs/*.html && rimraf -rf ./docs/api && rimraf -rf ./docs/tutorials/*.html && rimraf -rf ./docs/typescript/*.html && rimraf -rf ./docs/*.html && rimraf -rf ./docs/source/_docs && rimraf -rf ./tmp",
|
|
75
|
+
"docs:clean:legacy": "rimraf index.html && rimraf -rf ./docs/5.x && rimraf -rf ./docs/source/_docs && rimraf -rf ./tmp",
|
|
76
|
+
"docs:copy:tmp": "mkdirp ./tmp/docs/css && mkdirp ./tmp/docs/js && mkdirp ./tmp/docs/images && mkdirp ./tmp/docs/tutorials && mkdirp ./tmp/docs/typescript && ncp ./docs/css ./tmp/docs/css --filter=.css$ && ncp ./docs/js ./tmp/docs/js --filter=.js$ && ncp ./docs/images ./tmp/docs/images && ncp ./docs/tutorials ./tmp/docs/tutorials && ncp ./docs/typescript ./tmp/docs/typescript && cp index.html ./tmp",
|
|
77
|
+
"docs:copy:tmp:legacy": "rimraf ./docs/5.x && ncp ./tmp ./docs/5.x",
|
|
78
|
+
"docs:checkout:gh-pages": "git checkout gh-pages",
|
|
79
|
+
"docs:checkout:legacy": "git checkout 5.x",
|
|
80
|
+
"docs:generate": "node website.js",
|
|
81
|
+
"docs:generate:search": "node docs/search.js",
|
|
82
|
+
"docs:merge:stable": "git merge master",
|
|
83
|
+
"docs:merge:legacy": "git merge 5.x",
|
|
84
|
+
"docs:test": "npm run docs:generate && npm run docs:generate:search",
|
|
85
|
+
"docs:view": "node website.js && node static.js",
|
|
86
|
+
"docs:prepare:publish:stable": "npm run docs:checkout:gh-pages && npm run docs:merge:stable && npm run docs:clean:stable && npm run docs:generate && npm run docs:generate:search",
|
|
87
|
+
"docs:prepare:publish:legacy": "npm run docs:checkout:legacy && npm run docs:merge:legacy && npm run docs:clean:stable && npm run docs:generate && npm run docs:copy:tmp && docs:checkout:gh-pages && docs:copy:tmp:legacy",
|
|
70
88
|
"lint": "eslint .",
|
|
71
89
|
"lint-js": "eslint . --ext .js",
|
|
72
90
|
"lint-ts": "eslint . --ext .ts",
|
|
@@ -76,6 +94,7 @@
|
|
|
76
94
|
"release-legacy": "git pull origin 5.x && git push origin 5.x --tags && npm publish --tag legacy",
|
|
77
95
|
"mongo": "node ./tools/repl.js",
|
|
78
96
|
"test": "mocha --exit ./test/*.test.js",
|
|
97
|
+
"test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit ./test/*.test.js",
|
|
79
98
|
"test-tsd": "node ./test/types/check-types-filename && tsd",
|
|
80
99
|
"tdd": "mocha ./test/*.test.js ./test/typescript/main.test.js --inspect --watch --recursive --watch-files ./**/*.js",
|
|
81
100
|
"test-coverage": "nyc --reporter=html --reporter=text npm test"
|
|
@@ -119,6 +138,7 @@
|
|
|
119
138
|
"allowSyntheticDefaultImports": true,
|
|
120
139
|
"strictPropertyInitialization": false,
|
|
121
140
|
"noImplicitAny": false,
|
|
141
|
+
"strictNullChecks": true,
|
|
122
142
|
"module": "commonjs",
|
|
123
143
|
"target": "ES2017"
|
|
124
144
|
}
|
package/tsconfig.json
CHANGED
package/types/aggregate.d.ts
CHANGED
package/types/connection.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import mongodb = require('mongodb');
|
|
2
|
-
import events = require('events');
|
|
3
|
-
|
|
4
1
|
declare module 'mongoose' {
|
|
2
|
+
import mongodb = require('mongodb');
|
|
3
|
+
import events = require('events');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Connection ready state
|
|
@@ -73,7 +72,7 @@ declare module 'mongoose' {
|
|
|
73
72
|
* use this function to clean up any models you created in your tests to
|
|
74
73
|
* prevent OverwriteModelErrors.
|
|
75
74
|
*/
|
|
76
|
-
deleteModel(name: string): this;
|
|
75
|
+
deleteModel(name: string | RegExp): this;
|
|
77
76
|
|
|
78
77
|
/**
|
|
79
78
|
* Helper for `dropCollection()`. Will delete the given collection, including
|
package/types/cursor.d.ts
CHANGED
package/types/document.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import mongodb = require('mongodb');
|
|
2
|
-
|
|
3
1
|
declare module 'mongoose' {
|
|
2
|
+
import mongodb = require('mongodb');
|
|
4
3
|
|
|
5
4
|
/** A list of paths to skip. If set, Mongoose will validate every modified path that is not in this list. */
|
|
6
5
|
type pathsToSkip = string[] | string;
|
|
7
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Generic types for Document:
|
|
9
|
+
* * T - the type of _id
|
|
10
|
+
* * TQueryHelpers - Object with any helpers that should be mixed into the Query type
|
|
11
|
+
* * DocType - the type of the actual Document created
|
|
12
|
+
*/
|
|
8
13
|
class Document<T = any, TQueryHelpers = any, DocType = any> {
|
|
9
14
|
constructor(doc?: any);
|
|
10
15
|
|
|
@@ -186,10 +191,10 @@ declare module 'mongoose' {
|
|
|
186
191
|
$parent(): Document | undefined;
|
|
187
192
|
|
|
188
193
|
/** Populates document references. */
|
|
189
|
-
populate<Paths = {}>(path: string | PopulateOptions | (string | PopulateOptions)[], callback: Callback<this & Paths>): void;
|
|
190
|
-
populate<Paths = {}>(path: string, names: string, callback: Callback<this & Paths>): void;
|
|
191
|
-
populate<Paths = {}>(path: string, names: string): Promise<this & Paths>;
|
|
192
194
|
populate<Paths = {}>(path: string | PopulateOptions | (string | PopulateOptions)[]): Promise<this & Paths>;
|
|
195
|
+
populate<Paths = {}>(path: string | PopulateOptions | (string | PopulateOptions)[], callback: Callback<this & Paths>): void;
|
|
196
|
+
populate<Paths = {}>(path: string, select?: string | AnyObject, model?: Model<unknown>, match?: AnyObject, options?: PopulateOptions): Promise<this & Paths>;
|
|
197
|
+
populate<Paths = {}>(path: string, select?: string | AnyObject, model?: Model<unknown>, match?: AnyObject, options?: PopulateOptions, callback?: Callback<this & Paths>): void;
|
|
193
198
|
|
|
194
199
|
/** Gets _id(s) used during population of the given `path`. If the path was not populated, returns `undefined`. */
|
|
195
200
|
populated(path: string): any;
|
|
@@ -216,13 +221,11 @@ declare module 'mongoose' {
|
|
|
216
221
|
set(value: any): this;
|
|
217
222
|
|
|
218
223
|
/** The return value of this method is used in calls to JSON.stringify(doc). */
|
|
219
|
-
toJSON(options
|
|
220
|
-
toJSON(options
|
|
221
|
-
toJSON<T = FlattenMaps<DocType>>(options?: ToObjectOptions): T;
|
|
224
|
+
toJSON<T = LeanDocument<DocType>>(options?: ToObjectOptions & { flattenMaps?: true }): FlattenMaps<T>;
|
|
225
|
+
toJSON<T = LeanDocument<DocType>>(options: ToObjectOptions & { flattenMaps: false }): T;
|
|
222
226
|
|
|
223
227
|
/** Converts this document into a plain-old JavaScript object ([POJO](https://masteringjs.io/tutorials/fundamentals/pojo)). */
|
|
224
|
-
toObject(options?: ToObjectOptions):
|
|
225
|
-
toObject<T = DocType>(options?: ToObjectOptions): T;
|
|
228
|
+
toObject<T = LeanDocument<DocType>>(options?: ToObjectOptions): Require_id<T>;
|
|
226
229
|
|
|
227
230
|
/** Clears the modified state on the specified path. */
|
|
228
231
|
unmarkModified(path: string): void;
|
|
@@ -242,6 +245,6 @@ declare module 'mongoose' {
|
|
|
242
245
|
|
|
243
246
|
/** Executes registered validation rules (skipping asynchronous validators) for this document. */
|
|
244
247
|
validateSync(options: { pathsToSkip?: pathsToSkip, [k: string]: any }): Error.ValidationError | null;
|
|
245
|
-
validateSync(pathsToValidate?:
|
|
248
|
+
validateSync(pathsToValidate?: pathsToValidate, options?: AnyObject): Error.ValidationError | null;
|
|
246
249
|
}
|
|
247
|
-
}
|
|
250
|
+
}
|
package/types/error.d.ts
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
|
|
1
|
+
declare class NativeError extends global.Error { }
|
|
2
2
|
|
|
3
3
|
declare module 'mongoose' {
|
|
4
|
+
import mongodb = require('mongodb');
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
constructor(doc: Document, currentVersion: number, modifiedPaths: Array<string>);
|
|
127
|
-
}
|
|
6
|
+
type CallbackError = NativeError | null;
|
|
7
|
+
|
|
8
|
+
class MongooseError extends global.Error {
|
|
9
|
+
constructor(msg: string);
|
|
10
|
+
|
|
11
|
+
/** The type of error. "MongooseError" for generic errors. */
|
|
12
|
+
name: string;
|
|
13
|
+
|
|
14
|
+
static messages: any;
|
|
15
|
+
|
|
16
|
+
static Messages: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
namespace Error {
|
|
20
|
+
export class CastError extends MongooseError {
|
|
21
|
+
name: 'CastError';
|
|
22
|
+
stringValue: string;
|
|
23
|
+
kind: string;
|
|
24
|
+
value: any;
|
|
25
|
+
path: string;
|
|
26
|
+
reason?: NativeError | null;
|
|
27
|
+
model?: any;
|
|
28
|
+
|
|
29
|
+
constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
|
|
30
|
+
}
|
|
31
|
+
export class SyncIndexesError extends MongooseError {
|
|
32
|
+
name: 'SyncIndexesError';
|
|
33
|
+
errors?: Record<string, mongodb.MongoServerError>;
|
|
34
|
+
|
|
35
|
+
constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class DisconnectedError extends MongooseError {
|
|
39
|
+
name: 'DisconnectedError';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class DivergentArrayError extends MongooseError {
|
|
43
|
+
name: 'DivergentArrayError';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class MissingSchemaError extends MongooseError {
|
|
47
|
+
name: 'MissingSchemaError';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class DocumentNotFoundError extends MongooseError {
|
|
51
|
+
name: 'DocumentNotFoundError';
|
|
52
|
+
result: any;
|
|
53
|
+
numAffected: number;
|
|
54
|
+
filter: any;
|
|
55
|
+
query: any;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export class ObjectExpectedError extends MongooseError {
|
|
59
|
+
name: 'ObjectExpectedError';
|
|
60
|
+
path: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class ObjectParameterError extends MongooseError {
|
|
64
|
+
name: 'ObjectParameterError';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class OverwriteModelError extends MongooseError {
|
|
68
|
+
name: 'OverwriteModelError';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export class ParallelSaveError extends MongooseError {
|
|
72
|
+
name: 'ParallelSaveError';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class ParallelValidateError extends MongooseError {
|
|
76
|
+
name: 'ParallelValidateError';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class MongooseServerSelectionError extends MongooseError {
|
|
80
|
+
name: 'MongooseServerSelectionError';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class StrictModeError extends MongooseError {
|
|
84
|
+
name: 'StrictModeError';
|
|
85
|
+
isImmutableError: boolean;
|
|
86
|
+
path: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class ValidationError extends MongooseError {
|
|
90
|
+
name: 'ValidationError';
|
|
91
|
+
|
|
92
|
+
errors: { [path: string]: ValidatorError | CastError };
|
|
93
|
+
addError: (path: string, error: ValidatorError | CastError) => void;
|
|
94
|
+
|
|
95
|
+
constructor(instance?: MongooseError);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class ValidatorError extends MongooseError {
|
|
99
|
+
name: 'ValidatorError';
|
|
100
|
+
properties: {
|
|
101
|
+
message: string,
|
|
102
|
+
type?: string,
|
|
103
|
+
path?: string,
|
|
104
|
+
value?: any,
|
|
105
|
+
reason?: any
|
|
106
|
+
};
|
|
107
|
+
kind: string;
|
|
108
|
+
path: string;
|
|
109
|
+
value: any;
|
|
110
|
+
reason?: MongooseError | null;
|
|
111
|
+
|
|
112
|
+
constructor(properties: {
|
|
113
|
+
message?: string,
|
|
114
|
+
type?: string,
|
|
115
|
+
path?: string,
|
|
116
|
+
value?: any,
|
|
117
|
+
reason?: any
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export class VersionError extends MongooseError {
|
|
122
|
+
name: 'VersionError';
|
|
123
|
+
version: number;
|
|
124
|
+
modifiedPaths: Array<string>;
|
|
125
|
+
|
|
126
|
+
constructor(doc: Document, currentVersion: number, modifiedPaths: Array<string>);
|
|
128
127
|
}
|
|
128
|
+
}
|
|
129
129
|
}
|