summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Mir <ali.mir@mongodb.com>2020-08-25 10:46:31 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-16 00:52:14 +0000
commitb8b6d9fe5a5fb27efcdde48811b0eb9c9ca6a4a5 (patch)
tree66f4e6cb4e794e3c29f0505c86abf567fbd1324a
parent220d72da13180652f4986bc65a0dd95966973dd0 (diff)
downloadmongo-b8b6d9fe5a5fb27efcdde48811b0eb9c9ca6a4a5.tar.gz
SERVER-49989 Add db.hello() shell helper
(cherry picked from commit 27fda7a486ff4229f9037a132c3d8baa11121864)
-rw-r--r--src/mongo/shell/db.js5
-rw-r--r--src/mongo/shell/utils.js4
2 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js
index 9dc7d8635bb..4c0c7df6a15 100644
--- a/src/mongo/shell/db.js
+++ b/src/mongo/shell/db.js
@@ -595,6 +595,7 @@ DB.prototype.help = function() {
"\tdb.getWriteConcern() - returns the write concern used for any operations on this db, inherited from server object if set");
print("\tdb.hostInfo() get details about the server's host");
print("\tdb.isMaster() check replica primary status");
+ print("\tdb.hello() check replica primary status");
print("\tdb.killOp(opid) kills the current operation in the db");
print("\tdb.listCommands() lists all the db commands");
print("\tdb.loadServerScripts() loads all the scripts in db.system.js");
@@ -927,6 +928,10 @@ DB.prototype.isMaster = function() {
return this.runCommand("isMaster");
};
+DB.prototype.hello = function() {
+ return this.runCommand("hello");
+};
+
var commandUnsupported = function(res) {
return (!res.ok &&
(res.errmsg.startsWith("no such cmd") || res.errmsg.startsWith("no such command") ||
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js
index d474dcbeed7..5cc1481e7b3 100644
--- a/src/mongo/shell/utils.js
+++ b/src/mongo/shell/utils.js
@@ -1421,6 +1421,7 @@ rs.help = function() {
print(
"\trs.printSlaveReplicationInfo() check replica set members and replication lag");
print("\tdb.isMaster() check who is primary");
+ print("\tdb.hello() check who is primary");
print();
print("\treconfiguration helpers disconnect from the database so the shell will display");
print("\tan error, even if the command succeeds.");
@@ -1441,6 +1442,9 @@ rs.status = function() {
rs.isMaster = function() {
return db.isMaster();
};
+rs.hello = function() {
+ return db.hello();
+};
rs.initiate = function(c) {
return db._adminCommand({replSetInitiate: c});
};