-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
run_command.ts
73 lines (65 loc) · 2.87 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import type { BSONSerializeOptions, Document } from '../bson';
import type { ReadPreferenceLike } from '../read_preference';
import type { Server } from '../sdam/server';
import type { ClientSession } from '../sessions';
import { type Callback, MongoDBNamespace } from '../utils';
import { CommandOperation, type OperationParent } from './command';
/** @public */
export type RunCommandOptions = {
/** Specify ClientSession for this command */
session?: ClientSession;
/** The read preference */
readPreference?: ReadPreferenceLike;
// The following options were "accidentally" supported
// Since the options are generally supported through inheritance
/** @deprecated This is an internal option that has undefined behavior for this API */
willRetryWrite?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
omitReadPreference?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
writeConcern?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
explain?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
readConcern?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
collation?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
maxTimeMS?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
comment?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
retryWrites?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
dbName?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
authdb?: any;
/** @deprecated This is an internal option that has undefined behavior for this API */
noResponse?: any;
/** @internal Used for transaction commands */
bypassPinningCheck?: boolean;
} & BSONSerializeOptions;
/** @internal */
export class RunCommandOperation<T = Document> extends CommandOperation<T> {
override options: RunCommandOptions;
command: Document;
constructor(parent: OperationParent | undefined, command: Document, options?: RunCommandOptions) {
super(parent, options);
this.options = options ?? {};
this.command = command;
}
override executeCallback(
server: Server,
session: ClientSession | undefined,
callback: Callback<T>
): 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');
}
}