Skip to content

Commit ee2c37f

Browse files
W-A-Jamesnbbeeken
authored andcommitted
update docs
1 parent 306a955 commit ee2c37f

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/cursor/run_command_cursor.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,35 @@ export type RunCursorCommandOptions = {
2323
* `maxTimeMS` is provided in the command in addition to setting `timeoutMS` in the options, then
2424
* the original value of `maxTimeMS` will be overwritten. */
2525
timeoutMS?: number;
26-
/** See {@link CursorTimeoutMode} */
26+
/** @public
27+
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
28+
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
29+
* `cursor.next()`.
30+
* When set to `'cursorLifetime'`, the deadline applies to the life of the entire cursor.
31+
*
32+
* Depending on the type of cursor being used, this option has different default values.
33+
* For non-tailable cursors, this value defaults to `'cursorLifetime'`
34+
* For tailable cursors, this value defaults to `'iteration'` since tailable cursors, by
35+
* definition can have an arbitrarily long lifetime.
36+
*
37+
* @example
38+
* # Example showing use of `'iteration'`
39+
* ```ts
40+
* const cursor = collection.find({}, {timeoutMS: 100, timeoutMode: 'iteration'});
41+
* for await (const doc of cursor) {
42+
* // process doc
43+
* // This will throw a timeout error if any of the iterator's `next()` calls takes more than 100ms, but
44+
* will continue to iterate successfully otherwise, regardless of the number of batches.
45+
* }
46+
* ```
47+
*
48+
* # Example showing use of `'cursorLifetime'`
49+
*
50+
* ```ts
51+
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
52+
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
53+
* ```
54+
*/
2755
timeoutMode?: CursorTimeoutMode;
2856
tailable?: boolean;
2957
awaitData?: boolean;

src/gridfs/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ export interface GridFSBucketOptions extends WriteConcernOptions {
3838
chunkSizeBytes?: number;
3939
/** Read preference to be passed to read operations */
4040
readPreference?: ReadPreference;
41-
/** Specifies the time an operation will run until it throws a timeout error. Note that the
42-
* deadline specified by this option may be breached if calls to interact with the stream take
43-
* longer than the remaining timeout. FIXME(NODE-6456): what does this even mean?*/
41+
/** Specifies the lifetime duration of a gridFS stream. If any async operations are in progress
42+
* when this timeout expires, the stream will throw a timeout error. */
4443
timeoutMS?: number;
4544
}
4645

src/operations/indexes.ts

Lines changed: 1 addition & 1 deletion
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, type CursorTimeoutMode } from '../cursor/abstract_cursor';
4+
import { type AbstractCursorOptions } from '../cursor/abstract_cursor';
55
import { MongoCompatibilityError } from '../error';
66
import { type OneOrMore } from '../mongo_types';
77
import type { Server } from '../sdam/server';

0 commit comments

Comments
 (0)