summaryrefslogtreecommitdiff
path: root/jstests/mod1.js
blob: 91329b7733ab2fa0b89a9b3b135c8e52a92eecd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

t = db.mod1;
t.drop();

t.save( { a : 1 } );
t.save( { a : 2 } );
t.save( { a : 11 } );
t.save( { a : 20 } );

assert.eq( 2 , t.find( "this.a % 10 == 1" ).itcount() , "A" );
assert.eq( 2 , t.find( { a : { $mod : [ 10 , 1 ] } } ).itcount() , "B" );

t.ensureIndex( { a : 1 } );

assert.eq( 2 , t.find( "this.a % 10 == 1" ).itcount() , "C" );
assert.eq( 2 , t.find( { a : { $mod : [ 10 , 1 ] } } ).itcount() , "D" );

assert.eq( 1 , t.find( "this.a % 10 == 0" ).itcount() , "E" );
assert.eq( 1 , t.find( { a : { $mod : [ 10 , 0 ] } } ).itcount() , "F" );