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.
- package/.eslintrc.json +5 -1
- package/.lgtm.yml +3 -0
- package/CHANGELOG.md +54 -0
- package/dist/browser.umd.js +156 -152
- package/index.js +5 -1
- package/lib/aggregate.js +22 -27
- package/lib/browserDocument.js +1 -1
- package/lib/cast/number.js +2 -3
- package/lib/cast.js +7 -4
- package/lib/connection.js +43 -21
- package/lib/cursor/AggregationCursor.js +12 -7
- package/lib/cursor/QueryCursor.js +11 -6
- package/lib/document.js +58 -72
- 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/helpers/clone.js +11 -2
- package/lib/helpers/cursor/eachAsync.js +18 -15
- package/lib/helpers/document/cleanModifiedSubpaths.js +1 -0
- package/lib/helpers/document/compile.js +7 -4
- package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
- package/lib/helpers/indexes/getRelatedIndexes.js +59 -0
- package/lib/helpers/isAsyncFunction.js +6 -7
- package/lib/helpers/populate/assignVals.js +4 -0
- 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 +14 -19
- package/lib/helpers/query/hasDollarKeys.js +7 -3
- package/lib/helpers/query/isOperator.js +5 -2
- package/lib/helpers/schema/getIndexes.js +6 -2
- package/lib/index.js +14 -17
- package/lib/internal.js +9 -1
- package/lib/model.js +159 -153
- package/lib/options/SchemaTypeOptions.js +1 -1
- package/lib/plugins/trackTransaction.js +1 -1
- package/lib/query.js +159 -147
- package/lib/queryhelpers.js +8 -28
- package/lib/schema/SubdocumentPath.js +5 -4
- package/lib/schema/array.js +13 -6
- 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 -7
- package/lib/schema/number.js +1 -1
- package/lib/schema/objectid.js +1 -1
- package/lib/schema/string.js +4 -4
- package/lib/schema.js +12 -8
- package/lib/schematype.js +12 -14
- package/lib/types/ArraySubdocument.js +1 -1
- package/lib/types/DocumentArray/index.js +1 -1
- package/lib/types/array/index.js +2 -2
- package/lib/types/array/methods/index.js +10 -11
- package/lib/types/buffer.js +3 -3
- package/lib/types/map.js +3 -4
- package/lib/utils.js +9 -3
- package/package.json +17 -21
- package/tsconfig.json +0 -2
- package/types/Connection.d.ts +212 -0
- package/types/Error.d.ts +129 -0
- package/types/PipelineStage.d.ts +272 -0
- package/types/index.d.ts +61 -602
- package/lib/types/array/ArrayWrapper.js +0 -981
package/lib/utils.js
CHANGED
|
@@ -70,7 +70,7 @@ exports.deepEqual = function deepEqual(a, b) {
|
|
|
70
70
|
return true;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
if (typeof a !== 'object'
|
|
73
|
+
if (typeof a !== 'object' || typeof b !== 'object') {
|
|
74
74
|
return a === b;
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -102,7 +102,10 @@ exports.deepEqual = function deepEqual(a, b) {
|
|
|
102
102
|
return false;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
if (a instanceof Map
|
|
105
|
+
if (a instanceof Map || b instanceof Map) {
|
|
106
|
+
if (!(a instanceof Map) || !(b instanceof Map)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
106
109
|
return deepEqual(Array.from(a.keys()), Array.from(b.keys())) &&
|
|
107
110
|
deepEqual(Array.from(a.values()), Array.from(b.values()));
|
|
108
111
|
}
|
|
@@ -116,7 +119,10 @@ exports.deepEqual = function deepEqual(a, b) {
|
|
|
116
119
|
return exports.buffer.areEqual(a, b);
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
if (Array.isArray(a)
|
|
122
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
123
|
+
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
120
126
|
const len = a.length;
|
|
121
127
|
if (len !== b.length) {
|
|
122
128
|
return false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "6.2.
|
|
4
|
+
"version": "6.2.4",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -20,44 +20,41 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"bson": "^4.2.2",
|
|
23
|
-
"kareem": "2.3.
|
|
23
|
+
"kareem": "2.3.4",
|
|
24
24
|
"mongodb": "4.3.1",
|
|
25
25
|
"mpath": "0.8.4",
|
|
26
26
|
"mquery": "4.0.2",
|
|
27
|
-
"ms": "2.1.
|
|
28
|
-
"sift": "
|
|
27
|
+
"ms": "2.1.3",
|
|
28
|
+
"sift": "16.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@babel/core": "7.
|
|
32
|
-
"@babel/preset-env": "7.
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
34
|
-
"@typescript-eslint/parser": "5.
|
|
31
|
+
"@babel/core": "7.17.5",
|
|
32
|
+
"@babel/preset-env": "7.16.11",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "5.12.0",
|
|
34
|
+
"@typescript-eslint/parser": "5.12.0",
|
|
35
35
|
"acquit": "1.x",
|
|
36
|
-
"acquit-ignore": "0.
|
|
36
|
+
"acquit-ignore": "0.2.x",
|
|
37
37
|
"acquit-require": "0.1.x",
|
|
38
|
-
"babel-loader": "8.
|
|
38
|
+
"babel-loader": "8.2.3",
|
|
39
39
|
"benchmark": "2.1.4",
|
|
40
40
|
"bluebird": "3.7.2",
|
|
41
|
-
"cheerio": "1.0.0-rc.
|
|
41
|
+
"cheerio": "1.0.0-rc.10",
|
|
42
42
|
"dox": "0.3.1",
|
|
43
|
-
"eslint": "8.
|
|
44
|
-
"eslint-plugin-mocha-no-only": "1.1.
|
|
43
|
+
"eslint": "8.9.0",
|
|
44
|
+
"eslint-plugin-mocha-no-only": "1.1.1",
|
|
45
45
|
"highlight.js": "9.18.3",
|
|
46
|
-
"js-yaml": "4.1.0",
|
|
47
46
|
"lodash.isequal": "4.5.0",
|
|
48
47
|
"lodash.isequalwith": "4.4.0",
|
|
49
48
|
"marked": "2.1.3",
|
|
50
|
-
"
|
|
51
|
-
"mocha": "9.2.0",
|
|
49
|
+
"mocha": "9.2.1",
|
|
52
50
|
"moment": "2.x",
|
|
53
|
-
"mongodb-memory-server": "^8.
|
|
51
|
+
"mongodb-memory-server": "^8.3.0",
|
|
54
52
|
"nyc": "^15.1.0",
|
|
55
53
|
"pug": "3.0.2",
|
|
56
54
|
"q": "1.5.1",
|
|
57
|
-
"rimraf": "2.6.3",
|
|
58
55
|
"serve-handler": "6.1.3",
|
|
59
56
|
"tsd": "0.19.1",
|
|
60
|
-
"typescript": "4.5.
|
|
57
|
+
"typescript": "4.5.5",
|
|
61
58
|
"uuid": "8.3.2",
|
|
62
59
|
"webpack": "4.44.1"
|
|
63
60
|
},
|
|
@@ -73,7 +70,6 @@
|
|
|
73
70
|
"mongo": "node ./tools/repl.js",
|
|
74
71
|
"test": "mocha --exit ./test/*.test.js",
|
|
75
72
|
"test-tsd": "tsd",
|
|
76
|
-
"sym-link-mongoose": "npm link && npm link mongoose",
|
|
77
73
|
"tdd": "mocha ./test/*.test.js ./test/typescript/main.test.js --inspect --watch --recursive --watch-files ./**/*.js",
|
|
78
74
|
"test-coverage": "nyc --reporter=html --reporter=text npm test"
|
|
79
75
|
},
|
|
@@ -120,4 +116,4 @@
|
|
|
120
116
|
"target": "ES2017"
|
|
121
117
|
}
|
|
122
118
|
}
|
|
123
|
-
}
|
|
119
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import mongodb = require('mongodb');
|
|
2
|
+
import events = require('events');
|
|
3
|
+
|
|
4
|
+
declare module 'mongoose' {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Connection ready state
|
|
8
|
+
*
|
|
9
|
+
* - 0 = disconnected
|
|
10
|
+
* - 1 = connected
|
|
11
|
+
* - 2 = connecting
|
|
12
|
+
* - 3 = disconnecting
|
|
13
|
+
* - 99 = uninitialized
|
|
14
|
+
*/
|
|
15
|
+
export enum ConnectionStates {
|
|
16
|
+
disconnected = 0,
|
|
17
|
+
connected = 1,
|
|
18
|
+
connecting = 2,
|
|
19
|
+
disconnecting = 3,
|
|
20
|
+
uninitialized = 99,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Expose connection states for user-land */
|
|
24
|
+
export const STATES: typeof ConnectionStates;
|
|
25
|
+
|
|
26
|
+
interface ConnectOptions extends mongodb.MongoClientOptions {
|
|
27
|
+
/** Set to false to [disable buffering](http://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection. */
|
|
28
|
+
bufferCommands?: boolean;
|
|
29
|
+
/** The name of the database you want to use. If not provided, Mongoose uses the database name from connection string. */
|
|
30
|
+
dbName?: string;
|
|
31
|
+
/** username for authentication, equivalent to `options.auth.user`. Maintained for backwards compatibility. */
|
|
32
|
+
user?: string;
|
|
33
|
+
/** password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility. */
|
|
34
|
+
pass?: string;
|
|
35
|
+
/** Set to false to disable automatic index creation for all models associated with this connection. */
|
|
36
|
+
autoIndex?: boolean;
|
|
37
|
+
/** Set to `true` to make Mongoose automatically call `createCollection()` on every model created on this connection. */
|
|
38
|
+
autoCreate?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class Connection extends events.EventEmitter {
|
|
42
|
+
/** Returns a promise that resolves when this connection successfully connects to MongoDB */
|
|
43
|
+
asPromise(): Promise<this>;
|
|
44
|
+
|
|
45
|
+
/** Closes the connection */
|
|
46
|
+
close(force: boolean, callback: CallbackWithoutResult): void;
|
|
47
|
+
close(callback: CallbackWithoutResult): void;
|
|
48
|
+
close(force?: boolean): Promise<void>;
|
|
49
|
+
|
|
50
|
+
/** Retrieves a collection, creating it if not cached. */
|
|
51
|
+
collection<T extends AnyObject = AnyObject>(name: string, options?: mongodb.CreateCollectionOptions): Collection<T>;
|
|
52
|
+
|
|
53
|
+
/** A hash of the collections associated with this connection */
|
|
54
|
+
readonly collections: { [index: string]: Collection };
|
|
55
|
+
|
|
56
|
+
/** A hash of the global options that are associated with this connection */
|
|
57
|
+
readonly config: any;
|
|
58
|
+
|
|
59
|
+
/** The mongodb.Db instance, set when the connection is opened */
|
|
60
|
+
readonly db: mongodb.Db;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Helper for `createCollection()`. Will explicitly create the given collection
|
|
64
|
+
* with specified options. Used to create [capped collections](https://docs.mongodb.com/manual/core/capped-collections/)
|
|
65
|
+
* and [views](https://docs.mongodb.com/manual/core/views/) from mongoose.
|
|
66
|
+
*/
|
|
67
|
+
createCollection<T extends AnyObject = AnyObject>(name: string, options: mongodb.CreateCollectionOptions, callback: Callback<mongodb.Collection<T>>): void;
|
|
68
|
+
createCollection<T extends AnyObject = AnyObject>(name: string, callback: Callback<mongodb.Collection<T>>): void;
|
|
69
|
+
createCollection<T extends AnyObject = AnyObject>(name: string, options?: mongodb.CreateCollectionOptions): Promise<mongodb.Collection<T>>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Removes the model named `name` from this connection, if it exists. You can
|
|
73
|
+
* use this function to clean up any models you created in your tests to
|
|
74
|
+
* prevent OverwriteModelErrors.
|
|
75
|
+
*/
|
|
76
|
+
deleteModel(name: string): this;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Helper for `dropCollection()`. Will delete the given collection, including
|
|
80
|
+
* all documents and indexes.
|
|
81
|
+
*/
|
|
82
|
+
dropCollection(collection: string, callback: CallbackWithoutResult): void;
|
|
83
|
+
dropCollection(collection: string): Promise<void>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Helper for `dropDatabase()`. Deletes the given database, including all
|
|
87
|
+
* collections, documents, and indexes.
|
|
88
|
+
*/
|
|
89
|
+
dropDatabase(callback: CallbackWithoutResult): void;
|
|
90
|
+
dropDatabase(): Promise<void>;
|
|
91
|
+
|
|
92
|
+
/** Gets the value of the option `key`. */
|
|
93
|
+
get(key: string): any;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Returns the [MongoDB driver `MongoClient`](http://mongodb.github.io/node-mongodb-native/3.5/api/MongoClient.html) instance
|
|
97
|
+
* that this connection uses to talk to MongoDB.
|
|
98
|
+
*/
|
|
99
|
+
getClient(): mongodb.MongoClient;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The host name portion of the URI. If multiple hosts, such as a replica set,
|
|
103
|
+
* this will contain the first host name in the URI
|
|
104
|
+
*/
|
|
105
|
+
readonly host: string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A number identifier for this connection. Used for debugging when
|
|
109
|
+
* you have [multiple connections](/docs/connections.html#multiple_connections).
|
|
110
|
+
*/
|
|
111
|
+
readonly id: number;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A [POJO](https://masteringjs.io/tutorials/fundamentals/pojo) containing
|
|
115
|
+
* a map from model names to models. Contains all models that have been
|
|
116
|
+
* added to this connection using [`Connection#model()`](/docs/api/connection.html#connection_Connection-model).
|
|
117
|
+
*/
|
|
118
|
+
readonly models: Readonly<{ [index: string]: Model<any> }>;
|
|
119
|
+
|
|
120
|
+
/** Defines or retrieves a model. */
|
|
121
|
+
model<T, U, TQueryHelpers = {}>(
|
|
122
|
+
name: string,
|
|
123
|
+
schema?: Schema<T, U, TQueryHelpers>,
|
|
124
|
+
collection?: string,
|
|
125
|
+
options?: CompileModelOptions
|
|
126
|
+
): U;
|
|
127
|
+
model<T>(name: string, schema?: Schema<T>, collection?: string, options?: CompileModelOptions): Model<T>;
|
|
128
|
+
|
|
129
|
+
/** Returns an array of model names created on this connection. */
|
|
130
|
+
modelNames(): Array<string>;
|
|
131
|
+
|
|
132
|
+
/** The name of the database this connection points to. */
|
|
133
|
+
readonly name: string;
|
|
134
|
+
|
|
135
|
+
/** Opens the connection with a URI using `MongoClient.connect()`. */
|
|
136
|
+
openUri(uri: string, options: ConnectOptions, callback: Callback<Connection>): Connection;
|
|
137
|
+
openUri(uri: string, callback: Callback<Connection>): Connection;
|
|
138
|
+
openUri(uri: string, options?: ConnectOptions): Promise<Connection>;
|
|
139
|
+
|
|
140
|
+
/** The password specified in the URI */
|
|
141
|
+
readonly pass: string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The port portion of the URI. If multiple hosts, such as a replica set,
|
|
145
|
+
* this will contain the port from the first host name in the URI.
|
|
146
|
+
*/
|
|
147
|
+
readonly port: number;
|
|
148
|
+
|
|
149
|
+
/** Declares a plugin executed on all schemas you pass to `conn.model()` */
|
|
150
|
+
plugin<S extends Schema = Schema, O = AnyObject>(fn: (schema: S, opts?: any) => void, opts?: O): Connection;
|
|
151
|
+
|
|
152
|
+
/** The plugins that will be applied to all models created on this connection. */
|
|
153
|
+
plugins: Array<any>;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Connection ready state
|
|
157
|
+
*
|
|
158
|
+
* - 0 = disconnected
|
|
159
|
+
* - 1 = connected
|
|
160
|
+
* - 2 = connecting
|
|
161
|
+
* - 3 = disconnecting
|
|
162
|
+
* - 99 = uninitialized
|
|
163
|
+
*/
|
|
164
|
+
readonly readyState: ConnectionStates;
|
|
165
|
+
|
|
166
|
+
/** Sets the value of the option `key`. */
|
|
167
|
+
set(key: string, value: any): any;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Set the [MongoDB driver `MongoClient`](http://mongodb.github.io/node-mongodb-native/3.5/api/MongoClient.html) instance
|
|
171
|
+
* that this connection uses to talk to MongoDB. This is useful if you already have a MongoClient instance, and want to
|
|
172
|
+
* reuse it.
|
|
173
|
+
*/
|
|
174
|
+
setClient(client: mongodb.MongoClient): this;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* _Requires MongoDB >= 3.6.0._ Starts a [MongoDB session](https://docs.mongodb.com/manual/release-notes/3.6/#client-sessions)
|
|
178
|
+
* for benefits like causal consistency, [retryable writes](https://docs.mongodb.com/manual/core/retryable-writes/),
|
|
179
|
+
* and [transactions](http://thecodebarbarian.com/a-node-js-perspective-on-mongodb-4-transactions.html).
|
|
180
|
+
*/
|
|
181
|
+
startSession(options: mongodb.ClientSessionOptions | undefined | null, callback: Callback<mongodb.ClientSession>): void;
|
|
182
|
+
startSession(callback: Callback<mongodb.ClientSession>): void;
|
|
183
|
+
startSession(options?: mongodb.ClientSessionOptions): Promise<mongodb.ClientSession>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Makes the indexes in MongoDB match the indexes defined in every model's
|
|
187
|
+
* schema. This function will drop any indexes that are not defined in
|
|
188
|
+
* the model's schema except the `_id` index, and build any indexes that
|
|
189
|
+
* are in your schema but not in MongoDB.
|
|
190
|
+
*/
|
|
191
|
+
syncIndexes(options: SyncIndexesOptions | undefined | null, callback: Callback<ConnectionSyncIndexesResult>): void;
|
|
192
|
+
syncIndexes(options?: SyncIndexesOptions): Promise<ConnectionSyncIndexesResult>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* _Requires MongoDB >= 3.6.0._ Executes the wrapped async function
|
|
196
|
+
* in a transaction. Mongoose will commit the transaction if the
|
|
197
|
+
* async function executes successfully and attempt to retry if
|
|
198
|
+
* there was a retryable error.
|
|
199
|
+
*/
|
|
200
|
+
transaction<U = any>(fn: (session: mongodb.ClientSession) => Promise<U>): Promise<U>;
|
|
201
|
+
|
|
202
|
+
/** Switches to a different database using the same connection pool. */
|
|
203
|
+
useDb(name: string, options?: { useCache?: boolean, noListener?: boolean }): Connection;
|
|
204
|
+
|
|
205
|
+
/** The username specified in the URI */
|
|
206
|
+
readonly user: string;
|
|
207
|
+
|
|
208
|
+
/** Watches the entire underlying database for changes. Similar to [`Model.watch()`](/docs/api/model.html#model_Model.watch). */
|
|
209
|
+
watch<ResultType = any>(pipeline?: Array<any>, options?: mongodb.ChangeStreamOptions): mongodb.ChangeStream<ResultType>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
}
|
package/types/Error.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import mongodb = require('mongodb');
|
|
2
|
+
|
|
3
|
+
declare module 'mongoose' {
|
|
4
|
+
|
|
5
|
+
class NativeError extends global.Error { }
|
|
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>);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|