Skip to content

Commit

Permalink
remove API
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed May 16, 2023
1 parent 97ac778 commit fc57254
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions src/cursor/run_command_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MongoAPIError, MongoUnexpectedServerResponseError } from '../error';
import { executeOperation, ExecutionResult } from '../operations/execute_operation';
import { GetMoreOperation } from '../operations/get_more';
import { RunCommandOperation } from '../operations/run_command';
import type { ReadConcernLike } from '../read_concern';
import type { ReadPreferenceLike } from '../read_preference';
import type { ClientSession } from '../sessions';
import { Callback, ns } from '../utils';
Expand All @@ -30,22 +31,61 @@ export class RunCommandCursor extends AbstractCursor {
batchSize?: number;
} = {};

public setComment(comment: any) {
/**
* Controls the `getMore.comment` field
* @param comment - any BSON value
*/
public setComment(comment: any): this {
this.getMoreOptions.comment = comment;
return this;
}

public setMaxTimeMS(maxTimeMS: number) {
/**
* Controls the `getMore.maxTimeMS` field. Only valid when cursor is tailable await
* @param maxTimeMS - the number of milliseconds to wait for new data
*/
public setMaxTimeMS(maxTimeMS: number): this {
this.getMoreOptions.maxAwaitTimeMS = maxTimeMS;
return this;
}

public setBatchSize(batchSize: number) {
/**
* Controls the `getMore.batchSize` field
* @param maxTimeMS - the number documents to return in the `nextBatch`
*/
public setBatchSize(batchSize: number): this {
this.getMoreOptions.batchSize = batchSize;
return this;
}

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

public override withReadConcern(_: ReadConcernLike): never {
throw new MongoAPIError(
'RunCommandCursor does not support readConcern it must be attached to the command being run'
);
}

public override addCursorFlag(_: string, __: boolean): never {
throw new MongoAPIError(
'RunCommandCursor does not support cursor flags, they must be attached to the command being run'
);
}

public override maxTimeMS(_: number): never {
throw new MongoAPIError(
'RunCommandCursor does not support maxTimeMS, it must be attached to the command being run'
);
}

public override batchSize(_: number): never {
throw new MongoAPIError(
'RunCommandCursor does not support batchSize, it must be attached to the command being run'
);
}

/** @internal */
private db: Db | undefined;

Expand All @@ -61,7 +101,7 @@ export class RunCommandCursor extends AbstractCursor {
const operation = new RunCommandOperation<RunCursorCommandResponse>(this.db, this.command, {
...this.cursorOptions,
session: session,
readPreference: this.readPreference
readPreference: this.cursorOptions.readPreference
});
executeOperation(this.client, operation).then(
response => {
Expand Down

0 comments on commit fc57254

Please sign in to comment.