summaryrefslogtreecommitdiff
path: root/jstests/core/remove7.js
blob: 35662467c04c0ba9886c6c3179e5590808b68dfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

t = db.remove7
t.drop();



function getTags( n ){
    n = n || 5;
    var a = [];
    for ( var i=0; i<n; i++ ){
        var v = Math.ceil( 20 * Math.random() );
        a.push( v );
    }

    return a;
}

for ( i=0; i<1000; i++ ){
    t.save( { tags : getTags() } );
}

t.ensureIndex( { tags : 1 } );

for ( i=0; i<200; i++ ){
    for ( var j=0; j<10; j++ )
        t.save( { tags : getTags( 100 ) } );
    var q = { tags : { $in : getTags( 10 ) } };
    var before = t.find( q ).count();
    var res = t.remove( q );
    var after = t.find( q ).count();
    assert.eq( 0 , after , "not zero after!" );
    assert.writeOK( res );
}