summaryrefslogtreecommitdiff
path: root/jstests/core/count9.js
blob: 888ffe3b5445a743c8e4029edcac37649fe55215 (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
// Test fast mode count with multikey entries.

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

t.ensureIndex( {a:1} );

t.save( {a:['a','b','a']} );
assert.eq( 1, t.count( {a:'a'} ) );

t.save( {a:['a','b','a']} );
assert.eq( 2, t.count( {a:'a'} ) );

t.drop();
t.ensureIndex( {a:1,b:1} );

t.save( {a:['a','b','a'],b:'r'} );
assert.eq( 1, t.count( {a:'a',b:'r'} ) );
assert.eq( 1, t.count( {a:'a'} ) );

t.save( {a:['a','b','a'],b:'r'} );
assert.eq( 2, t.count( {a:'a',b:'r'} ) );
assert.eq( 2, t.count( {a:'a'} ) );

t.drop();
t.ensureIndex( {'a.b':1,'a.c':1} );
t.save( {a:[{b:'b',c:'c'},{b:'b',c:'c'}]} );
assert.eq( 1, t.count( {'a.b':'b','a.c':'c'} ) );