-
Type: Task
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: manual
-
Labels:None
I believe this was introduced in 2.1, but I'm not certain.
> db.foo.copyTo function ( newName ){ return this.getDB().eval( function( collName , newName ){ var from = db[collName]; var to = db[newName]; to.ensureIndex( { _id : 1 } ); var count = 0; var cursor = from.find(); while ( cursor.hasNext() ){ var o = cursor.next(); count++; to.save( o ); } return count; } , this.getName() , newName ); }