Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 303x 303x 303x 147223x 147223x 147223x 147223x 147039x 146921x 146921x 143801x 303x 835922x 835922x 835922x 835922x 836499x 836455x 836455x 824656x | import type { BSONSerializeOptions, Document } from '../bson';
import { type MongoDBResponseConstructor } from '../cmap/wire_protocol/responses';
import { type Db } from '../db';
import { type TODO_NODE_3286 } from '../mongo_types';
import type { ReadPreferenceLike } from '../read_preference';
import type { Server } from '../sdam/server';
import type { ClientSession } from '../sessions';
import { type TimeoutContext } from '../timeout';
import { MongoDBNamespace } from '../utils';
import { AbstractOperation } from './operation';
/** @public */
export type RunCommandOptions = {
/** Specify ClientSession for this command */
session?: ClientSession;
/** The read preference */
readPreference?: ReadPreferenceLike;
/**
* @experimental
* Specifies the time an operation will run until it throws a timeout error
*/
timeoutMS?: number;
/** @internal */
omitMaxTimeMS?: boolean;
} & BSONSerializeOptions;
/** @internal */
export class RunCommandOperation<T = Document> extends AbstractOperation<T> {
constructor(
parent: Db,
public command: Document,
public override options: RunCommandOptions & { responseType?: MongoDBResponseConstructor }
) {
super(options);
this.ns = parent.s.namespace.withCollection('$cmd');
}
override get commandName() {
return 'runCommand' as const;
}
override async execute(
server: Server,
session: ClientSession | undefined,
timeoutContext: TimeoutContext
): Promise<T> {
this.server = server;
const res: TODO_NODE_3286 = await server.command(
this.ns,
this.command,
{
...this.options,
readPreference: this.readPreference,
session,
timeoutContext
},
this.options.responseType
);
return res;
}
}
export class RunAdminCommandOperation<T = Document> extends AbstractOperation<T> {
constructor(
public command: Document,
public override options: RunCommandOptions & {
noResponse?: boolean;
bypassPinningCheck?: boolean;
}
) {
super(options);
this.ns = new MongoDBNamespace('admin', '$cmd');
}
override get commandName() {
return 'runCommand' as const;
}
override async execute(
server: Server,
session: ClientSession | undefined,
timeoutContext: TimeoutContext
): Promise<T> {
this.server = server;
const res: TODO_NODE_3286 = await server.command(this.ns, this.command, {
...this.options,
readPreference: this.readPreference,
session,
timeoutContext
});
return res;
}
}
|