11import { type Abortable } from '..' ;
22import type { BSONSerializeOptions , Document } from '../bson' ;
33import { type Connection } from '../cmap/connection' ;
4- import {
5- CursorResponse ,
6- MongoDBResponse ,
7- type MongoDBResponseConstructor
8- } from '../cmap/wire_protocol/responses' ;
9- import { type Db } from '../db' ;
4+ import { CursorResponse , MongoDBResponse } from '../cmap/wire_protocol/responses' ;
5+ import { ModernizedOperation } from '../operations/operation' ;
106import type { ReadPreferenceLike } from '../read_preference' ;
117import type { ServerCommandOptions } from '../sdam/server' ;
128import type { ClientSession } from '../sessions' ;
139import { type TimeoutContext } from '../timeout' ;
14- import { MongoDBNamespace } from '../utils' ;
15- import { ModernizedCommandOperation } from './command' ;
10+ import { type MongoDBNamespace } from '../utils' ;
1611
1712/** @public */
1813export type RunCommandOptions = {
@@ -27,31 +22,33 @@ export type RunCommandOptions = {
2722 timeoutMS ?: number ;
2823 /** @internal */
2924 omitMaxTimeMS ?: boolean ;
25+
26+ /**
27+ * @internal Hints to `executeOperation` that this operation should not unpin on an ended transaction
28+ * This is only used by the driver for transaction commands
29+ */
30+ bypassPinningCheck ?: boolean ;
3031} & BSONSerializeOptions &
3132 Abortable ;
3233
3334/** @internal */
34- export class RunCommandOperation < T = Document > extends ModernizedCommandOperation < T > {
35+ export class RunCommandOperation < T = Document > extends ModernizedOperation < T > {
3536 override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse ;
3637 command : Document ;
37- override options : RunCommandOptions & { responseType ?: MongoDBResponseConstructor } ;
38+ override options : RunCommandOptions ;
3839
39- constructor (
40- parent : Db ,
41- command : Document ,
42- options : RunCommandOptions & { responseType ?: MongoDBResponseConstructor }
43- ) {
44- super ( undefined , options ) ;
40+ constructor ( namespace : MongoDBNamespace , command : Document , options : RunCommandOptions ) {
41+ super ( options ) ;
4542 this . command = command ;
4643 this . options = options ;
47- this . ns = parent . s . namespace . withCollection ( '$cmd' ) ;
44+ this . ns = namespace . withCollection ( '$cmd' ) ;
4845 }
4946
5047 override get commandName ( ) {
5148 return 'runCommand' as const ;
5249 }
5350
54- override buildCommandDocument ( _connection : Connection , _session ?: ClientSession ) : Document {
51+ override buildCommand ( _connection : Connection , _session ?: ClientSession ) : Document {
5552 return this . command ;
5653 }
5754
@@ -79,37 +76,3 @@ export class RunCursorCommandOperation extends RunCommandOperation {
7976 return response ;
8077 }
8178}
82-
83- export class RunAdminCommandOperation < T = Document > extends ModernizedCommandOperation < T > {
84- override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse ;
85- command : Document ;
86- override options : RunCommandOptions & {
87- noResponse ?: boolean ;
88- bypassPinningCheck ?: boolean ;
89- } ;
90-
91- constructor (
92- command : Document ,
93- options : RunCommandOptions & {
94- noResponse ?: boolean ;
95- bypassPinningCheck ?: boolean ;
96- }
97- ) {
98- super ( undefined , options ) ;
99- this . command = command ;
100- this . options = options ;
101- this . ns = new MongoDBNamespace ( 'admin' , '$cmd' ) ;
102- }
103-
104- override get commandName ( ) {
105- return 'runCommand' as const ;
106- }
107-
108- override buildCommandDocument ( _connection : Connection , _session ?: ClientSession ) : Document {
109- return this . command ;
110- }
111-
112- override buildOptions ( timeoutContext : TimeoutContext ) : ServerCommandOptions {
113- return { session : this . session , timeoutContext, noResponse : this . options . noResponse } ;
114- }
115- }
0 commit comments