/
run_command.ts
32 lines (27 loc) · 1.12 KB
/
run_command.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import type { Document } from '../bson';
import type { Server } from '../sdam/server';
import type { ClientSession } from '../sessions';
import { Callback, MongoDBNamespace } from '../utils';
import { CommandOperation, CommandOperationOptions, OperationParent } from './command';
/** @public */
export type RunCommandOptions = CommandOperationOptions;
/** @internal */
export class RunCommandOperation<T = Document> extends CommandOperation<T> {
options: RunCommandOptions;
command: Document;
constructor(parent: OperationParent | undefined, command: Document, options?: RunCommandOptions) {
super(parent, options);
this.options = options ?? {};
this.command = command;
}
execute(server: Server, session: ClientSession, callback: Callback): void {
const command = this.command;
this.executeCommand(server, session, command, callback);
}
}
export class RunAdminCommandOperation<T = Document> extends RunCommandOperation<T> {
constructor(parent: OperationParent | undefined, command: Document, options?: RunCommandOptions) {
super(parent, command, options);
this.ns = new MongoDBNamespace('admin');
}
}