mongoose 6.2.10 → 6.3.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.
- package/.eslintrc.json +157 -157
- package/dist/browser.umd.js +2 -1693
- package/lib/aggregate.js +23 -31
- package/lib/collection.js +0 -7
- package/lib/cursor/ChangeStream.js +42 -2
- package/lib/cursor/QueryCursor.js +2 -0
- package/lib/document.js +13 -19
- package/lib/error/cast.js +7 -2
- package/lib/error/eachAsyncMultiError.js +41 -0
- package/lib/helpers/cursor/eachAsync.js +44 -12
- package/lib/helpers/indexes/applySchemaCollation.js +13 -0
- package/lib/helpers/indexes/isTextIndex.js +16 -0
- package/lib/helpers/model/discriminator.js +1 -3
- package/lib/helpers/populate/getModelsMapForPopulate.js +13 -10
- package/lib/helpers/query/applyGlobalOption.js +29 -0
- package/lib/helpers/query/castUpdate.js +3 -1
- package/lib/helpers/schematype/handleImmutable.js +4 -1
- package/lib/helpers/timestamps/setupTimestamps.js +2 -2
- package/lib/helpers/update/applyTimestampsToChildren.js +2 -2
- package/lib/helpers/update/applyTimestampsToUpdate.js +0 -1
- package/lib/index.js +11 -4
- package/lib/model.js +36 -36
- package/lib/query.js +59 -26
- package/lib/queryhelpers.js +11 -1
- package/lib/schema/SubdocumentPath.js +2 -1
- package/lib/schema/documentarray.js +2 -4
- package/lib/schema/objectid.js +0 -3
- package/lib/schema/string.js +24 -2
- package/lib/schema.js +117 -3
- package/lib/schematype.js +2 -3
- package/lib/types/DocumentArray/methods/index.js +1 -1
- package/lib/types/array/methods/index.js +9 -10
- package/lib/types/subdocument.js +29 -0
- package/lib/validoptions.js +1 -0
- package/package.json +13 -7
- package/tools/repl.js +2 -1
- package/tsconfig.json +2 -1
- package/types/aggregate.d.ts +223 -0
- package/types/connection.d.ts +2 -2
- package/types/cursor.d.ts +10 -4
- package/types/document.d.ts +3 -3
- package/types/index.d.ts +200 -215
- package/types/mongooseoptions.d.ts +10 -4
- package/CHANGELOG.md +0 -7227
- package/History.md +0 -1
- package/lib/helpers/query/applyGlobalMaxTimeMS.js +0 -15
package/types/connection.d.ts
CHANGED
|
@@ -197,7 +197,7 @@ declare module 'mongoose' {
|
|
|
197
197
|
* async function executes successfully and attempt to retry if
|
|
198
198
|
* there was a retryable error.
|
|
199
199
|
*/
|
|
200
|
-
transaction
|
|
200
|
+
transaction(fn: (session: mongodb.ClientSession) => Promise<any>): Promise<void>;
|
|
201
201
|
|
|
202
202
|
/** Switches to a different database using the same connection pool. */
|
|
203
203
|
useDb(name: string, options?: { useCache?: boolean, noListener?: boolean }): Connection;
|
|
@@ -206,7 +206,7 @@ declare module 'mongoose' {
|
|
|
206
206
|
readonly user: string;
|
|
207
207
|
|
|
208
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>;
|
|
209
|
+
watch<ResultType extends mongodb.Document = any>(pipeline?: Array<any>, options?: mongodb.ChangeStreamOptions): mongodb.ChangeStream<ResultType>;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
}
|
package/types/cursor.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import stream = require('stream');
|
|
|
3
3
|
declare module 'mongoose' {
|
|
4
4
|
type CursorFlag = 'tailable' | 'oplogReplay' | 'noCursorTimeout' | 'awaitData' | 'partial';
|
|
5
5
|
|
|
6
|
+
interface EachAsyncOptions {
|
|
7
|
+
parallel?: number;
|
|
8
|
+
batchSize?: number;
|
|
9
|
+
continueOnError?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
class Cursor<DocType = any, Options = never> extends stream.Readable {
|
|
7
13
|
[Symbol.asyncIterator](): AsyncIterableIterator<DocType>;
|
|
8
14
|
|
|
@@ -25,10 +31,10 @@ declare module 'mongoose' {
|
|
|
25
31
|
* will wait for the promise to resolve before iterating on to the next one.
|
|
26
32
|
* Returns a promise that resolves when done.
|
|
27
33
|
*/
|
|
28
|
-
eachAsync(fn: (doc: DocType[]) => any, options:
|
|
29
|
-
eachAsync(fn: (doc: DocType) => any, options:
|
|
30
|
-
eachAsync(fn: (doc: DocType[]) => any, options:
|
|
31
|
-
eachAsync(fn: (doc: DocType) => any, options?:
|
|
34
|
+
eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }, callback: CallbackWithoutResult): void;
|
|
35
|
+
eachAsync(fn: (doc: DocType) => any, options: EachAsyncOptions, callback: CallbackWithoutResult): void;
|
|
36
|
+
eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }): Promise<void>;
|
|
37
|
+
eachAsync(fn: (doc: DocType) => any, options?: EachAsyncOptions): Promise<void>;
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* Registers a transform function which subsequently maps documents retrieved
|
package/types/document.d.ts
CHANGED
|
@@ -49,6 +49,9 @@ declare module 'mongoose' {
|
|
|
49
49
|
/** Marks a path as valid, removing existing validation errors. */
|
|
50
50
|
$markValid(path: string): void;
|
|
51
51
|
|
|
52
|
+
/** Returns the model with the given name on this document's associated connection. */
|
|
53
|
+
$model<ModelType = Model<unknown>>(name: string): ModelType;
|
|
54
|
+
|
|
52
55
|
/**
|
|
53
56
|
* A string containing the current operation that Mongoose is executing
|
|
54
57
|
* on this document. Can be `null`, `'save'`, `'validate'`, or `'remove'`.
|
|
@@ -169,9 +172,6 @@ declare module 'mongoose' {
|
|
|
169
172
|
/** The name of the model */
|
|
170
173
|
modelName: string;
|
|
171
174
|
|
|
172
|
-
/** Returns the model with the given name on this document's associated connection. */
|
|
173
|
-
model<ModelType = Model<unknown>>(name: string): ModelType;
|
|
174
|
-
|
|
175
175
|
/**
|
|
176
176
|
* Overwrite all values in this document with the values of `obj`, except
|
|
177
177
|
* for immutable properties. Behaves similarly to `set()`, except for it
|