diff options
Diffstat (limited to 'src/mongo/shell/db.js')
-rw-r--r-- | src/mongo/shell/db.js | 75 |
1 files changed, 18 insertions, 57 deletions
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js index 6330b9abe32..4f98467f840 100644 --- a/src/mongo/shell/db.js +++ b/src/mongo/shell/db.js @@ -62,10 +62,7 @@ var DB; // The server selection spec mandates that the key is '$query', but // the shell has historically used 'query'. The server accepts both, // so we maintain the existing behavior - var cmdObjWithReadPref = { - query: clonedCmdObj, - $readPreference: readPref - }; + var cmdObjWithReadPref = {query: clonedCmdObj, $readPreference: readPref}; return cmdObjWithReadPref; }; @@ -233,9 +230,7 @@ var DB; options.flags = flags; } - var cmd = { - create: name - }; + var cmd = {create: name}; Object.extend(cmd, options); return this._dbCommand(cmd); @@ -288,9 +283,7 @@ var DB; return "shutdown command only works with the admin database; try 'use admin'"; } - var cmd = { - 'shutdown': 1 - }; + var cmd = {'shutdown': 1}; opts = opts || {}; for (var o in opts) { cmd[o] = opts[o]; @@ -531,9 +524,7 @@ var DB; throw errorObject; } - var cmd = { - profile: level - }; + var cmd = {profile: level}; if (isNumber(slowms)) cmd["slowms"] = slowms; return assert.commandWorked(this._dbCommand(cmd)); @@ -566,9 +557,7 @@ var DB; DB.prototype.eval = function(jsfunction) { print("WARNING: db.eval is deprecated"); - var cmd = { - $eval: jsfunction - }; + var cmd = {$eval: jsfunction}; if (arguments.length > 1) { cmd.args = Array.from(arguments).slice(1); } @@ -697,9 +686,7 @@ var DB; return res.err; }; DB.prototype.getLastErrorObj = function(w, wtimeout) { - var cmd = { - getlasterror: 1 - }; + var cmd = {getlasterror: 1}; if (w) { cmd.w = w; if (wtimeout) @@ -825,9 +812,7 @@ var DB; q["$all"] = true; } - var commandObj = { - "currentOp": 1 - }; + var commandObj = {"currentOp": 1}; Object.extend(commandObj, q); var res = this.adminCommand(commandObj); if (commandUnsupported(res)) { @@ -1081,9 +1066,7 @@ var DB; }; DB.prototype.serverStatus = function(options) { - var cmd = { - serverStatus: 1 - }; + var cmd = {serverStatus: 1}; if (options) { Object.extend(cmd, options); } @@ -1200,10 +1183,7 @@ var DB; ///////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// - var _defaultWriteConcern = { - w: 'majority', - wtimeout: 30 * 1000 - }; + var _defaultWriteConcern = {w: 'majority', wtimeout: 30 * 1000}; function getUserObjString(userObj) { var pwd = userObj.pwd; @@ -1237,9 +1217,7 @@ var DB; DB.prototype.createUser = function(userObj, writeConcern) { var name = userObj["user"]; - var cmdObj = { - createUser: name - }; + var cmdObj = {createUser: name}; cmdObj = Object.extend(cmdObj, userObj); delete cmdObj["user"]; @@ -1299,9 +1277,7 @@ var DB; }; DB.prototype.updateUser = function(name, updateObject, writeConcern) { - var cmdObj = { - updateUser: name - }; + var cmdObj = {updateUser: name}; cmdObj = Object.extend(cmdObj, updateObject); cmdObj['writeConcern'] = writeConcern ? writeConcern : _defaultWriteConcern; this._modifyCommandToDigestPasswordIfNecessary(cmdObj, name); @@ -1412,10 +1388,7 @@ var DB; DB.prototype._authOrThrow = function() { var params; if (arguments.length == 2) { - params = { - user: arguments[0], - pwd: arguments[1] - }; + params = {user: arguments[0], pwd: arguments[1]}; } else if (arguments.length == 1) { if (typeof(arguments[0]) != "object") throw Error("Single-argument form of auth expects a parameter object"); @@ -1490,9 +1463,7 @@ var DB; if (typeof username != "string") { throw Error("User name for getUser shell helper must be a string"); } - var cmdObj = { - usersInfo: username - }; + var cmdObj = {usersInfo: username}; Object.extend(cmdObj, args); var res = this.runCommand(cmdObj); @@ -1507,9 +1478,7 @@ var DB; }; DB.prototype.getUsers = function(args) { - var cmdObj = { - usersInfo: 1 - }; + var cmdObj = {usersInfo: 1}; Object.extend(cmdObj, args); var res = this.runCommand(cmdObj); if (!res.ok) { @@ -1528,9 +1497,7 @@ var DB; DB.prototype.createRole = function(roleObj, writeConcern) { var name = roleObj["role"]; - var cmdObj = { - createRole: name - }; + var cmdObj = {createRole: name}; cmdObj = Object.extend(cmdObj, roleObj); delete cmdObj["role"]; cmdObj["writeConcern"] = writeConcern ? writeConcern : _defaultWriteConcern; @@ -1544,9 +1511,7 @@ var DB; }; DB.prototype.updateRole = function(name, updateObject, writeConcern) { - var cmdObj = { - updateRole: name - }; + var cmdObj = {updateRole: name}; cmdObj = Object.extend(cmdObj, updateObject); cmdObj['writeConcern'] = writeConcern ? writeConcern : _defaultWriteConcern; var res = this.runCommand(cmdObj); @@ -1638,9 +1603,7 @@ var DB; if (typeof rolename != "string") { throw Error("Role name for getRole shell helper must be a string"); } - var cmdObj = { - rolesInfo: rolename - }; + var cmdObj = {rolesInfo: rolename}; Object.extend(cmdObj, args); var res = this.runCommand(cmdObj); if (!res.ok) { @@ -1654,9 +1617,7 @@ var DB; }; DB.prototype.getRoles = function(args) { - var cmdObj = { - rolesInfo: 1 - }; + var cmdObj = {rolesInfo: 1}; Object.extend(cmdObj, args); var res = this.runCommand(cmdObj); if (!res.ok) { |