diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-02-24 13:12:37 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-02-24 13:12:37 -0500 |
commit | e0b1d9f7638098f56e246dc2347e3cd7815f3346 (patch) | |
tree | a7396036135737cd7b792fbd5be768e99204d806 /shell | |
parent | c0e6f059435869604765b4059e6188c9e5b2a357 (diff) | |
download | mongo-e0b1d9f7638098f56e246dc2347e3cd7815f3346.tar.gz |
db.foo.runCommand for running commands with a collection name
Diffstat (limited to 'shell')
-rw-r--r-- | shell/collection.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/shell/collection.js b/shell/collection.js index 3535e2007ca..2567f6d42ea 100644 --- a/shell/collection.js +++ b/shell/collection.js @@ -50,6 +50,7 @@ DBCollection.prototype.help = function() { print("\tdb.foo.mapReduce( mapFunction , reduceFunction , <optional params> )"); print("\tdb.foo.remove(query)"); print("\tdb.foo.renameCollection( newName , <dropTarget> ) renames the collection."); + print("\tdb.foo.runCommand( name , <options> ) runs a db command with the given name where the 1st param is the colleciton name" ); print("\tdb.foo.save(obj)"); print("\tdb.foo.stats()"); print("\tdb.foo.storageSize() - includes free space allocated to this collection"); @@ -67,10 +68,19 @@ DBCollection.prototype.getDB = function(){ return this._db; } -DBCollection.prototype._dbCommand = function( cmd ){ - return this._db._dbCommand( cmd ); +DBCollection.prototype._dbCommand = function( cmd , params ){ + if ( typeof( cmd ) == "object" ) + return this._db._dbCommand( cmd ); + + var c = {}; + c[cmd] = this.getName(); + if ( params ) + Object.extend( c , params ); + return this._db._dbCommand( c ); } +DBCollection.prototype.runCommand = DBCollection.prototype._dbCommand; + DBCollection.prototype._massageObject = function( q ){ if ( ! q ) return {}; @@ -407,7 +417,7 @@ DBCollection.prototype.dropIndex = function(index) { if ( ! isString( index ) && isObject( index ) ) index = this._genIndexName( index ); - var res = this._dbCommand( { deleteIndexes: this.getName(), index: index } ); + var res = this._dbCommand( "deleteIndexes" ,{ index: index } ); this.resetIndexCache(); return res; } |