summaryrefslogtreecommitdiff
path: root/jstests/core/count9.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/count9.js')
-rw-r--r--jstests/core/count9.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/jstests/core/count9.js b/jstests/core/count9.js
new file mode 100644
index 00000000000..888ffe3b544
--- /dev/null
+++ b/jstests/core/count9.js
@@ -0,0 +1,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'} ) );