summaryrefslogtreecommitdiff
path: root/src/mongo/shell/db.js
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@10gen.com>2013-11-08 18:02:05 -0500
committerSpencer T Brody <spencer@10gen.com>2013-11-13 19:01:57 -0500
commit4d5ba6b01fa2d38640ba5bc8bf5c99f305e619bf (patch)
tree4a2483cda1f7f8abf250bac9cda6c83d75613856 /src/mongo/shell/db.js
parent7688ccdf103191f89ed3c285889f9264dba48d8a (diff)
downloadmongo-4d5ba6b01fa2d38640ba5bc8bf5c99f305e619bf.tar.gz
SERVER-11411 Give rolesInfo command the ability to list all roles defined for a given database.
This commit also introduces the "showPrivileges" option, which defaults to false, to rolesInfo to control whether or not privilege information is included in the result.
Diffstat (limited to 'src/mongo/shell/db.js')
-rw-r--r--src/mongo/shell/db.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js
index 1a32c091258..c74a65e2bf7 100644
--- a/src/mongo/shell/db.js
+++ b/src/mongo/shell/db.js
@@ -1373,11 +1373,13 @@ DB.prototype.revokePrivilegesFromRole = function(rolename, privileges, writeConc
}
}
-DB.prototype.getRole = function(rolename) {
+DB.prototype.getRole = function(rolename, args) {
if (typeof rolename != "string") {
throw Error("Role name for getRole shell helper must be a string");
}
- var res = this.runCommand({rolesInfo: rolename});
+ var cmdObj = {rolesInfo:rolename};
+ Object.extend(cmdObj, args);
+ var res = this.runCommand(cmdObj);
if (!res.ok) {
throw Error(res.errmsg);
}
@@ -1388,4 +1390,15 @@ DB.prototype.getRole = function(rolename) {
return res.roles[0];
}
+DB.prototype.getRoles = function(args) {
+ var cmdObj = {rolesInfo:1};
+ Object.extend(cmdObj, args);
+ var res = this.runCommand(cmdObj);
+ if (!res.ok) {
+ throw Error(res.errmsg);
+ }
+
+ return res.roles;
+}
+
}());