@@ -14,7 +14,6 @@ import { type TimeoutContext } from '../timeout';
1414import { MongoDBNamespace } from '../utils' ;
1515import { type WriteConcern } from '../write_concern' ;
1616import { ModernizedCommandOperation } from './command' ;
17- import { ModernizedOperation } from './operation' ;
1817
1918/** @public */
2019export type RunCommandOptions = {
@@ -58,38 +57,23 @@ export class RunCommandOperation<T = Document> extends ModernizedCommandOperatio
5857 }
5958
6059 override buildOptions ( timeoutContext : TimeoutContext ) : ServerCommandOptions {
61- return { session : this . session , timeoutContext, signal : this . options . signal } ;
60+ return {
61+ session : this . session ,
62+ timeoutContext,
63+ signal : this . options . signal ,
64+ readPreference : this . options . readPreference
65+ } ;
6266 }
6367}
6468
65- /** @internal */
66- export class RunCursorCommandOperation extends ModernizedOperation < CursorResponse > {
69+ /**
70+ * @internal
71+ *
72+ * A specialized subclass of RunCommandOperation for cursor-creating commands.
73+ */
74+ export class RunCursorCommandOperation extends RunCommandOperation {
6775 override SERVER_COMMAND_RESPONSE_TYPE = CursorResponse ;
68- command : Document ;
69- override options : RunCommandOptions & { responseType ?: MongoDBResponseConstructor } ;
70-
71- constructor (
72- parent : Db ,
73- command : Document ,
74- options : RunCommandOptions & { responseType ?: MongoDBResponseConstructor }
75- ) {
76- super ( options ) ;
77- this . command = command ;
78- this . options = options ;
79- this . ns = parent . s . namespace . withCollection ( '$cmd' ) ;
80- }
81-
82- override get commandName ( ) {
83- return 'runCommand' as const ;
84- }
8576
86- override buildCommand ( _connection : Connection , _session ?: ClientSession ) : Document {
87- return this . command ;
88- }
89-
90- override buildOptions ( timeoutContext : TimeoutContext ) : ServerCommandOptions {
91- return { session : this . session , timeoutContext } ;
92- }
9377 override handleOk (
9478 response : InstanceType < typeof this . SERVER_COMMAND_RESPONSE_TYPE >
9579 ) : CursorResponse {
0 commit comments