File: capped4.js

package info (click to toggle)
mongodb 1%3A1.4.4-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,816 kB
  • ctags: 11,368
  • sloc: cpp: 58,805; ansic: 18,160; python: 1,255; sh: 238; makefile: 82
file content (28 lines) | stat: -rw-r--r-- 739 bytes parent folder | download
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
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; t.findOne( { i:19 } ); ++i ) {
    t.save( { i : i } );
}
//assert( !t.findOne( { i : 19 } ), "A" );
assert( !c.hasNext(), "B" );
assert( !d.hasNext(), "C" );
assert( t.find().sort( { i : 1 } ).hint( { i : 1 } ).toArray().length > 10, "D" );

assert( t.findOne( { i : i - 1 } ), "E" );
t.remove( { i : i - 1 } );
assert( db.getLastError().indexOf( "capped" ) >= 0, "F" );

assert( t.validate().valid, "G" );