2009-01-27 05:28:26 +01:00
|
|
|
// remove.js
|
|
|
|
// unit test for db remove
|
|
|
|
|
|
|
|
t = db.removetest;
|
|
|
|
|
|
|
|
function f(n,dir) {
|
|
|
|
t.ensureIndex({x:dir||1});
|
|
|
|
for( i = 0; i < n; i++ ) t.save( { x:3, z:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } );
|
|
|
|
|
2009-01-27 05:35:26 +01:00
|
|
|
assert.eq( n , t.find().count() );
|
2009-01-27 05:28:26 +01:00
|
|
|
t.remove({x:3});
|
2009-01-27 05:35:26 +01:00
|
|
|
|
|
|
|
assert.eq( 0 , t.find().count() );
|
|
|
|
|
|
|
|
assert( t.findOne() == null , "A:" + tojson( t.findOne() ) );
|
|
|
|
assert( t.validate().valid , "B" );
|
2009-01-27 05:28:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
t.drop();
|
|
|
|
f(300, 1);
|
|
|
|
|
|
|
|
f(500, -1);
|
|
|
|
|
2009-01-27 05:35:26 +01:00
|
|
|
assert(t.validate().valid , "C" );
|
|
|
|
|