diff options
author | Matt Cotter <matt.cotter@mongodb.com> | 2016-09-01 17:06:51 -0400 |
---|---|---|
committer | Matt Cotter <matt.cotter@mongodb.com> | 2016-09-02 09:19:19 -0400 |
commit | 03b26cf2e15deb65326f7be7d0b5a94f7ca5471c (patch) | |
tree | 281783f4b0bf4900e19d2e144908d9ff791c9e54 /src/mongo/shell | |
parent | 9dd6ba84b674356bf9a31ce416a383c8d559fcbd (diff) | |
download | mongo-03b26cf2e15deb65326f7be7d0b5a94f7ca5471c.tar.gz |
SERVER-7295 check arguments to rename collection helper
Diffstat (limited to 'src/mongo/shell')
-rw-r--r-- | src/mongo/shell/collection.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/shell/collection.js b/src/mongo/shell/collection.js index 6c70ee8da87..7005583ff95 100644 --- a/src/mongo/shell/collection.js +++ b/src/mongo/shell/collection.js @@ -771,6 +771,19 @@ DBCollection.prototype.findAndModify = function(args) { }; DBCollection.prototype.renameCollection = function(newName, dropTarget) { + if (arguments.length === 1 && typeof newName === 'object') { + if (newName.hasOwnProperty('dropTarget')) { + dropTarget = newName['dropTarget']; + } + newName = newName['to']; + } + if (typeof dropTarget === 'undefined') { + dropTarget = false; + } + if (typeof newName !== 'string' || typeof dropTarget !== 'boolean') { + throw Error( + 'renameCollection must either take a string and an optional boolean or an object.'); + } return this._db._adminCommand({ renameCollection: this._fullName, to: this._db._name + "." + newName, |