diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-05-20 14:50:33 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-05-20 14:50:33 -0400 |
commit | 3cebde86be21d03bd74fbbd0dd069a714e16b6da (patch) | |
tree | dad426b3cfed82a8961cb518e25c98af5c78fb8d | |
parent | b8c6d85506d04c3b9d9b804fcf6d1e763b55f963 (diff) | |
download | mongo-3cebde86be21d03bd74fbbd0dd069a714e16b6da.tar.gz |
converToCappend on collection
-rw-r--r-- | jstests/capped3.js | 5 | ||||
-rw-r--r-- | shell/collection.js | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/jstests/capped3.js b/jstests/capped3.js index 4bb6dcc4ea5..7c047b53d63 100644 --- a/jstests/capped3.js +++ b/jstests/capped3.js @@ -32,11 +32,12 @@ t2.drop(); for( i = 0; i < 1000; ++i ) { t.save( {i:i} ); } -assert.commandWorked( db.runCommand( { convertToCapped:"jstests_capped3", size:1000 } ) ); +//assert.commandWorked( db.runCommand( { convertToCapped:"jstests_capped3", size:1000 } ) ); +t.convertToCapped( 1000 ) c = t.find().sort( {$natural:-1} ); i = 999; while( c.hasNext() ) { assert.eq( i--, c.next().i ); } assert( i < 990 ); -assert( i > 900 );
\ No newline at end of file +assert( i > 900 ); diff --git a/shell/collection.js b/shell/collection.js index 12eba186f7c..558255ee5d0 100644 --- a/shell/collection.js +++ b/shell/collection.js @@ -348,6 +348,12 @@ DBCollection.prototype.totalIndexSize = function(){ return total; } +DBCollection.prototype.convertToCapped = function( bytes ){ + if ( ! bytes ) + throw "have to specify # of bytes"; + return this._dbCommand( { convertToCapped : this._shortName , size : bytes } ) +} + DBCollection.prototype.toString = function(){ return this.getFullName(); } |