Skip to content

Commit c9e1c68

Browse files
committed
add timeoutMode to find, findOne, listIndexes, aggregate, listCollections
1 parent b2bad87 commit c9e1c68

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ export interface CursorStreamOptions {
5959
/** @public */
6060
export type CursorFlag = (typeof CURSOR_FLAGS)[number];
6161

62+
export const CursorTimeoutMode = Object.freeze({
63+
ITERATION: 'iteration',
64+
LIFETIME: 'lifetime'
65+
} as const);
66+
67+
export type CursorTimeoutMode = (typeof CursorTimeoutMode)[keyof typeof CursorTimeoutMode];
68+
6269
/** @public */
6370
export interface AbstractCursorOptions extends BSONSerializeOptions {
6471
session?: ClientSession;

src/operations/aggregate.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Document } from '../bson';
22
import { CursorResponse, ExplainedCursorResponse } from '../cmap/wire_protocol/responses';
3+
import { type CursorTimeoutMode } from '../cursor/abstract_cursor';
34
import { MongoInvalidArgumentError } from '../error';
45
import type { Server } from '../sdam/server';
56
import type { ClientSession } from '../sessions';
@@ -35,6 +36,9 @@ export interface AggregateOptions extends CommandOperationOptions {
3536
let?: Document;
3637

3738
out?: string;
39+
40+
/** @internal */
41+
timeoutMode?: CursorTimeoutMode;
3842
}
3943

4044
/** @internal */

src/operations/find.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Document } from '../bson';
22
import { CursorResponse, ExplainedCursorResponse } from '../cmap/wire_protocol/responses';
3+
import { type CursorTimeoutMode } from '../cursor/abstract_cursor';
34
import { MongoInvalidArgumentError } from '../error';
45
import { ReadConcern } from '../read_concern';
56
import type { Server } from '../sdam/server';
@@ -64,6 +65,9 @@ export interface FindOptions<TSchema extends Document = Document>
6465
* @deprecated Starting from MongoDB 4.4 this flag is not needed and will be ignored.
6566
*/
6667
oplogReplay?: boolean;
68+
69+
/** @internal*/
70+
timeoutMode?: CursorTimeoutMode;
6771
}
6872

6973
/** @internal */

src/operations/indexes.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Document } from '../bson';
22
import { CursorResponse } from '../cmap/wire_protocol/responses';
33
import type { Collection } from '../collection';
4-
import { type AbstractCursorOptions } from '../cursor/abstract_cursor';
4+
import { type AbstractCursorOptions, type CursorTimeoutMode } from '../cursor/abstract_cursor';
55
import { MongoCompatibilityError } from '../error';
66
import { type OneOrMore } from '../mongo_types';
77
import type { Server } from '../sdam/server';
@@ -360,7 +360,9 @@ export class DropIndexOperation extends CommandOperation<Document> {
360360
}
361361

362362
/** @public */
363-
export type ListIndexesOptions = AbstractCursorOptions;
363+
export type ListIndexesOptions = AbstractCursorOptions & {
364+
timeoutMode?: CursorTimeoutMode;
365+
};
364366

365367
/** @internal */
366368
export class ListIndexesOperation extends CommandOperation<CursorResponse> {

src/operations/list_collections.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Binary, Document } from '../bson';
22
import { CursorResponse } from '../cmap/wire_protocol/responses';
3+
import { type CursorTimeoutMode } from '../cursor/abstract_cursor';
34
import type { Db } from '../db';
45
import type { Server } from '../sdam/server';
56
import type { ClientSession } from '../sessions';
@@ -16,6 +17,8 @@ export interface ListCollectionsOptions extends Omit<CommandOperationOptions, 'w
1617
authorizedCollections?: boolean;
1718
/** The batchSize for the returned command cursor or if pre 2.8 the systems batch collection */
1819
batchSize?: number;
20+
/** @internal */
21+
timeoutMode?: CursorTimeoutMode;
1922
}
2023

2124
/** @internal */

0 commit comments

Comments
 (0)