1 | declare module 'mongoose' {
|
2 |
|
3 | import stream = require('stream');
|
4 |
|
5 | type CursorFlag = 'tailable' | 'oplogReplay' | 'noCursorTimeout' | 'awaitData' | 'partial';
|
6 |
|
7 | interface EachAsyncOptions {
|
8 | parallel?: number;
|
9 | batchSize?: number;
|
10 | continueOnError?: boolean;
|
11 | }
|
12 |
|
13 | class Cursor<DocType = any, Options = never> extends stream.Readable {
|
14 | [Symbol.asyncIterator](): AsyncIterableIterator<DocType>;
|
15 |
|
16 | |
17 |
|
18 |
|
19 |
|
20 | addCursorFlag(flag: CursorFlag, value: boolean): this;
|
21 |
|
22 | |
23 |
|
24 |
|
25 |
|
26 | close(callback: CallbackWithoutResult): void;
|
27 | close(): Promise<void>;
|
28 |
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }, callback: CallbackWithoutResult): void;
|
36 | eachAsync(fn: (doc: DocType) => any, options: EachAsyncOptions, callback: CallbackWithoutResult): void;
|
37 | eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }): Promise<void>;
|
38 | eachAsync(fn: (doc: DocType) => any, options?: EachAsyncOptions): Promise<void>;
|
39 |
|
40 | |
41 |
|
42 |
|
43 |
|
44 | map<ResultType>(fn: (res: DocType) => ResultType): Cursor<ResultType, Options>;
|
45 |
|
46 | /**
|
47 | * Get the next document from this cursor. Will return `null` when there are
|
48 | * no documents left.
|
49 | */
|
50 | next(callback: Callback<DocType | null>): void;
|
51 | next(): Promise<DocType>;
|
52 |
|
53 | options: Options;
|
54 | }
|
55 | }
|
56 |
|
\ | No newline at end of file |