mongo-debian/jstests/capped_empty.js
2012-08-29 20:54:51 +02:00

24 lines
502 B
JavaScript

t = db.capped_empty;
t.drop();
db.createCollection( t.getName() , { capped : true , size : 100 } )
t.insert( { x : 1 } );
t.insert( { x : 2 } );
t.insert( { x : 3 } );
t.ensureIndex( { x : 1 } );
assert.eq( 3 , t.count() );
assert.eq( 1 , t.find( { x : 2 } ).explain().nscanned );
t.runCommand( "emptycapped" );
assert.eq( 0 , t.count() );
t.insert( { x : 1 } );
t.insert( { x : 2 } );
t.insert( { x : 3 } );
assert.eq( 3 , t.count() );
assert.eq( 1 , t.find( { x : 2 } ).explain().nscanned );