0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

Merge branch 'master' of github.com:mongodb/mongo

This commit is contained in:
Aaron 2009-09-07 10:39:42 -07:00
commit 2b14dc6134
2 changed files with 24 additions and 0 deletions

19
jstests/rename2.js Normal file
View File

@ -0,0 +1,19 @@
a = db.rename2a;
b = db.rename2b;
a.drop();
b.drop();
a.save( { x : 1 } )
a.save( { x : 2 } )
a.save( { x : 3 } )
assert.eq( 3 , a.count() , "A" )
assert.eq( 0 , b.count() , "B" )
assert( a.renameCollection( "rename2b" ) , "the command" );
assert.eq( 0 , a.count() , "C" )
assert.eq( 3 , b.count() , "D" )

View File

@ -44,6 +44,7 @@ DBCollection.prototype.help = function(){
print("\tdb.foo.dropIndex(name)");
print("\tdb.foo.getIndexes()");
print("\tdb.foo.drop() drop the collection");
print("\tdb.foo.renameCollection( newName ) renames the collection");
print("\tdb.foo.validate() - SLOW");
print("\tdb.foo.stats()");
print("\tdb.foo.dataSize()");
@ -294,6 +295,10 @@ DBCollection.prototype.drop = function(){
return this._db.runCommand( { drop: this.getName() } );
}
DBCollection.prototype.renameCollection = function( newName ){
return this._db._adminCommand( { renameCollection : this._fullName , to : this._db._name + "." + newName } ).ok;
}
DBCollection.prototype.validate = function() {
var res = this._db.runCommand( { validate: this.getName() } );