Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/sync/node_modules/mongodb/lib/operations/ drwxr-xr-x | |
| Viewing file: Select action/file-type: "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommandOperation = void 0;
const error_1 = require("../error");
const explain_1 = require("../explain");
const read_concern_1 = require("../read_concern");
const utils_1 = require("../utils");
const write_concern_1 = require("../write_concern");
const operation_1 = require("./operation");
/** @internal */
class CommandOperation extends operation_1.AbstractOperation {
constructor(parent, options) {
super(options);
this.options = options ?? {};
// NOTE: this was explicitly added for the add/remove user operations, it's likely
// something we'd want to reconsider. Perhaps those commands can use `Admin`
// as a parent?
const dbNameOverride = options?.dbName || options?.authdb;
if (dbNameOverride) {
this.ns = new utils_1.MongoDBNamespace(dbNameOverride, '$cmd');
}
else {
this.ns = parent
? parent.s.namespace.withCollection('$cmd')
: new utils_1.MongoDBNamespace('admin', '$cmd');
}
this.readConcern = read_concern_1.ReadConcern.fromOptions(options);
this.writeConcern = write_concern_1.WriteConcern.fromOptions(options);
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE)) {
this.explain = explain_1.Explain.fromOptions(options);
if (this.explain)
(0, explain_1.validateExplainTimeoutOptions)(this.options, this.explain);
}
else if (options?.explain != null) {
throw new error_1.MongoInvalidArgumentError(`Option "explain" is not supported on this command`);
}
}
get canRetryWrite() {
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE)) {
return this.explain == null;
}
return super.canRetryWrite;
}
buildOptions(timeoutContext) {
return {
...this.options,
...this.bsonOptions,
timeoutContext,
readPreference: this.readPreference,
session: this.session
};
}
buildCommand(connection, session) {
const command = this.buildCommandDocument(connection, session);
const inTransaction = this.session && this.session.inTransaction();
if (this.readConcern && (0, utils_1.commandSupportsReadConcern)(command) && !inTransaction) {
Object.assign(command, { readConcern: this.readConcern });
}
if (this.writeConcern && this.hasAspect(operation_1.Aspect.WRITE_OPERATION) && !inTransaction) {
write_concern_1.WriteConcern.apply(command, this.writeConcern);
}
if (this.options.collation &&
typeof this.options.collation === 'object' &&
!this.hasAspect(operation_1.Aspect.SKIP_COLLATION)) {
Object.assign(command, { collation: this.options.collation });
}
if (typeof this.options.maxTimeMS === 'number') {
command.maxTimeMS = this.options.maxTimeMS;
}
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE) && this.explain) {
return (0, explain_1.decorateWithExplain)(command, this.explain);
}
return command;
}
}
exports.CommandOperation = CommandOperation;
//# sourceMappingURL=command.js.map |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0213 ]-- |