Skip to content

Commit fc57254

Browse files
committed
remove API
1 parent 97ac778 commit fc57254

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

src/cursor/run_command_cursor.ts

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MongoAPIError, MongoUnexpectedServerResponseError } from '../error';
44
import { executeOperation, ExecutionResult } from '../operations/execute_operation';
55
import { GetMoreOperation } from '../operations/get_more';
66
import { RunCommandOperation } from '../operations/run_command';
7+
import type { ReadConcernLike } from '../read_concern';
78
import type { ReadPreferenceLike } from '../read_preference';
89
import type { ClientSession } from '../sessions';
910
import { Callback, ns } from '../utils';
@@ -30,22 +31,61 @@ export class RunCommandCursor extends AbstractCursor {
3031
batchSize?: number;
3132
} = {};
3233

33-
public setComment(comment: any) {
34+
/**
35+
* Controls the `getMore.comment` field
36+
* @param comment - any BSON value
37+
*/
38+
public setComment(comment: any): this {
3439
this.getMoreOptions.comment = comment;
40+
return this;
3541
}
3642

37-
public setMaxTimeMS(maxTimeMS: number) {
43+
/**
44+
* Controls the `getMore.maxTimeMS` field. Only valid when cursor is tailable await
45+
* @param maxTimeMS - the number of milliseconds to wait for new data
46+
*/
47+
public setMaxTimeMS(maxTimeMS: number): this {
3848
this.getMoreOptions.maxAwaitTimeMS = maxTimeMS;
49+
return this;
3950
}
4051

41-
public setBatchSize(batchSize: number) {
52+
/**
53+
* Controls the `getMore.batchSize` field
54+
* @param maxTimeMS - the number documents to return in the `nextBatch`
55+
*/
56+
public setBatchSize(batchSize: number): this {
4257
this.getMoreOptions.batchSize = batchSize;
58+
return this;
4359
}
4460

4561
public clone(): never {
4662
throw new MongoAPIError('RunCommandCursor cannot be cloned');
4763
}
4864

65+
public override withReadConcern(_: ReadConcernLike): never {
66+
throw new MongoAPIError(
67+
'RunCommandCursor does not support readConcern it must be attached to the command being run'
68+
);
69+
}
70+
71+
public override addCursorFlag(_: string, __: boolean): never {
72+
throw new MongoAPIError(
73+
'RunCommandCursor does not support cursor flags, they must be attached to the command being run'
74+
);
75+
}
76+
77+
public override maxTimeMS(_: number): never {
78+
throw new MongoAPIError(
79+
'RunCommandCursor does not support maxTimeMS, it must be attached to the command being run'
80+
);
81+
}
82+
83+
public override batchSize(_: number): never {
84+
throw new MongoAPIError(
85+
'RunCommandCursor does not support batchSize, it must be attached to the command being run'
86+
);
87+
}
88+
4989
/** @internal */
5090
private db: Db | undefined;
5191

@@ -61,7 +101,7 @@ export class RunCommandCursor extends AbstractCursor {
61101
const operation = new RunCommandOperation<RunCursorCommandResponse>(this.db, this.command, {
62102
...this.cursorOptions,
63103
session: session,
64-
readPreference: this.readPreference
104+
readPreference: this.cursorOptions.readPreference
65105
});
66106
executeOperation(this.client, operation).then(
67107
response => {

0 commit comments

Comments
 (0)