summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands.cpp')
-rw-r--r--src/mongo/db/commands.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp
index f7aa71e9184..9f3afeda2a4 100644
--- a/src/mongo/db/commands.cpp
+++ b/src/mongo/db/commands.cpp
@@ -186,7 +186,7 @@ ResourcePattern Command::parseResourcePattern(const std::string& dbname,
return ResourcePattern::forExactNamespace(NamespaceString(ns));
}
-Command::Command(StringData name, StringData oldName)
+Command::Command(StringData name, std::vector<StringData> aliases)
: _name(name.toString()),
_commandsExecutedMetric("commands." + _name + ".total", &_commandsExecuted),
_commandsFailedMetric("commands." + _name + ".failed", &_commandsFailed) {
@@ -201,8 +201,12 @@ Command::Command(StringData name, StringData oldName)
c = this;
(*_commandsByBestName)[name] = this;
- if (!oldName.empty())
- (*_commands)[oldName.toString()] = this;
+ for (auto key : aliases) {
+ if (key.empty()) {
+ continue;
+ }
+ (*_commands)[key.toString()] = this;
+ }
}
void Command::help(stringstream& help) const {
@@ -388,6 +392,10 @@ void Command::generateHelpResponse(OperationContext* opCtx,
replyBuilder->setMetadata(rpc::makeEmptyMetadata());
}
+bool Command::hasAlias(const StringData& alias) const {
+ return findCommand(alias) == this;
+}
+
namespace {
const stdx::unordered_set<std::string> userManagementCommands{"createUser",
"updateUser",