summaryrefslogtreecommitdiff
path: root/jstests/in.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/in.js')
-rw-r--r--jstests/in.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/jstests/in.js b/jstests/in.js
new file mode 100644
index 0000000..5442bbe
--- /dev/null
+++ b/jstests/in.js
@@ -0,0 +1,19 @@
+
+t = db.in1;
+t.drop();
+
+t.save( { a : 1 } );
+t.save( { a : 2 } );
+
+assert.eq( 1 , t.find( { a : { $in : [ 1 ] } } ).itcount() , "A" );
+assert.eq( 1 , t.find( { a : { $in : [ 2 ] } } ).itcount() , "B" );
+assert.eq( 2 , t.find( { a : { $in : [ 1 , 2 ] } } ).itcount() , "C" );
+
+t.ensureIndex( { a : 1 } );
+
+assert.eq( 1 , t.find( { a : { $in : [ 1 ] } } ).itcount(), "D" );
+assert.eq( 1 , t.find( { a : { $in : [ 2 ] } } ).itcount() , "E" );
+assert.eq( 2 , t.find( { a : { $in : [ 1 , 2 ] } } ).itcount() , "F" );
+
+assert.eq( 0 , t.find( { a : { $in : [] } } ).itcount() , "G" );
+