summaryrefslogtreecommitdiff
path: root/jstests/capped4.js
blob: 9d4735b92f6466ed84ac7b6c3e3ee5eb6f5fc05e (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
t = db.jstests_capped4;
t.drop();

db.createCollection( "jstests_capped4", {size:1000,capped:true} );
t.ensureIndex( { i: 1 } );
for( i = 0; i < 20; ++i ) {
    t.save( { i : i } );
}
c = t.find().sort( { $natural: -1 } ).limit( 2 );
c.next();
c.next();
d = t.find().sort( { i: -1 } ).limit( 2 );
d.next();
d.next();

for( i = 20; i < 40; ++i ) {
    t.save( { i : i } );
}
assert( !t.findOne( { i : 19 } ) );
assert( !c.hasNext() );
assert( !d.hasNext() );
assert( t.find().sort( { i : 1 } ).hint( { i : 1 } ).toArray().length > 10 );

assert( t.validate().valid );