diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-08-20 13:00:50 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-20 18:12:14 +0000 |
commit | d3064df927c97abd402ee5768ab57667ed6849c9 (patch) | |
tree | c246336371b545bdc5942dab73aef5c094d99bd4 /src/mongo/shell/db.js | |
parent | 526230bafa6e5a49f5783507734fba93486c19ae (diff) | |
download | mongo-d3064df927c97abd402ee5768ab57667ed6849c9.tar.gz |
SERVER-49380 Add API params to mongo shell
Diffstat (limited to 'src/mongo/shell/db.js')
-rw-r--r-- | src/mongo/shell/db.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js index dc492dd6ffc..44c9a9b24d9 100644 --- a/src/mongo/shell/db.js +++ b/src/mongo/shell/db.js @@ -197,6 +197,16 @@ DB.prototype.adminCommand = function(obj, extra) { DB.prototype._adminCommand = DB.prototype.adminCommand; // alias old name +DB.prototype._runCommandWithoutApiStrict = function(command) { + let commandWithoutApiStrict = Object.assign({}, command); + if (this.getMongo().getApiParameters().strict) { + // Permit this command invocation, even if it's not in the requested API version. + commandWithoutApiStrict["apiStrict"] = false; + } + + return this.runCommand(commandWithoutApiStrict); +}; + DB.prototype._runAggregate = function(cmdObj, aggregateOptions) { assert(cmdObj.pipeline instanceof Array, "cmdObj must contain a 'pipeline' array"); assert(cmdObj.aggregate !== undefined, "cmdObj must contain 'aggregate' field"); @@ -1104,7 +1114,8 @@ DB.prototype.printSecondaryReplicationInfo = function() { var L = this.getSiblingDB("local"); if (L.system.replset.count() != 0) { - var status = this.adminCommand({'replSetGetStatus': 1}); + const status = + this.getSiblingDB('admin')._runCommandWithoutApiStrict({'replSetGetStatus': 1}); primary = getPrimary(status.members); if (primary) { startOptimeDate = primary.optimeDate; @@ -1126,7 +1137,7 @@ DB.prototype.printSecondaryReplicationInfo = function() { }; DB.prototype.serverBuildInfo = function() { - return this._adminCommand("buildinfo"); + return this.getSiblingDB("admin")._runCommandWithoutApiStrict({buildinfo: 1}); }; // Used to trim entries from the metrics.commands that have never been executed |