Skip to content

Commit 471620a

Browse files
committed
fix: run admin command
1 parent 93bbf5a commit 471620a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/mongo_client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
794794
this,
795795
new RunAdminCommandOperation(
796796
{ endSessions },
797-
{ readPreference: ReadPreference.primaryPreferred, noResponse: true }
797+
{ readPreference: ReadPreference.primaryPreferred, writeConcern: { w: 0 } }
798798
)
799799
);
800800
} catch (error) {

src/operations/run_command.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import type { ServerCommandOptions } from '../sdam/server';
1111
import type { ClientSession } from '../sessions';
1212
import { type TimeoutContext } from '../timeout';
1313
import { MongoDBNamespace } from '../utils';
14+
import { type WriteConcern } from '../write_concern';
15+
import { ModernizedCommandOperation } from './command';
1416
import { ModernizedOperation } from './operation';
1517

1618
/** @public */
@@ -93,22 +95,22 @@ export class RunCursorCommandOperation extends ModernizedOperation<CursorRespons
9395
}
9496
}
9597

96-
export class RunAdminCommandOperation<T = Document> extends ModernizedOperation<T> {
98+
export class RunAdminCommandOperation<T = Document> extends ModernizedCommandOperation<T> {
9799
override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse;
98100
command: Document;
99101
override options: RunCommandOptions & {
100-
noResponse?: boolean;
102+
writeConcern?: WriteConcern;
101103
bypassPinningCheck?: boolean;
102104
};
103105

104106
constructor(
105107
command: Document,
106108
options: RunCommandOptions & {
107-
noResponse?: boolean;
109+
writeConcern?: WriteConcern;
108110
bypassPinningCheck?: boolean;
109111
}
110112
) {
111-
super(options);
113+
super(undefined, options);
112114
this.command = command;
113115
this.options = options;
114116
this.ns = new MongoDBNamespace('admin', '$cmd');
@@ -118,7 +120,7 @@ export class RunAdminCommandOperation<T = Document> extends ModernizedOperation<
118120
return 'runCommand' as const;
119121
}
120122

121-
override buildCommand(_connection: Connection, _session?: ClientSession): Document {
123+
override buildCommandDocument(_connection: Connection, _session?: ClientSession): Document {
122124
return this.command;
123125
}
124126

0 commit comments

Comments
 (0)