summaryrefslogtreecommitdiff
path: root/jstests/find4.js
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-06-20 21:38:45 -0400
committerEliot Horowitz <eliot@10gen.com>2009-06-20 21:38:45 -0400
commit7fdff9e044891bf09530579d3d8946b87dc29cb5 (patch)
treef06b64f96f21b0074e7395279fea5ecf1dbad1f7 /jstests/find4.js
parent285b43af2503e5ee81cf9d88cc8d40393295333f (diff)
downloadmongo-7fdff9e044891bf09530579d3d8946b87dc29cb5.tar.gz
test for field filters MINOR
Diffstat (limited to 'jstests/find4.js')
-rw-r--r--jstests/find4.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/find4.js b/jstests/find4.js
new file mode 100644
index 00000000000..17639d3a684
--- /dev/null
+++ b/jstests/find4.js
@@ -0,0 +1,26 @@
+
+t = db.find4;
+t.drop();
+
+t.save( { a : 1123 , b : 54332 } );
+
+o = t.find( {} , {} )[0];
+assert.eq( 1123 , o.a , "A" );
+assert.eq( 54332 , o.b , "B" );
+assert( o._id.str , "C" );
+
+o = t.find( {} , { a : 1 } )[0];
+assert.eq( 1123 , o.a , "D" );
+assert( o._id.str , "E" );
+assert( ! o.b , "F" );
+
+o = t.find( {} , { b : 1 } )[0];
+assert.eq( 54332 , o.b , "G" );
+assert( o._id.str , "H" );
+assert( ! o.a , "I" );
+
+t.drop();
+t.save( { a : 1 , b : 1 } );
+t.save( { a : 2 , b : 2 } );
+assert.eq( "1-1,2-2" , t.find().map( function(z){ return z.a + "-" + z.b } ).toString() );
+assert.eq( "1-undefined,2-undefined" , t.find( {} , { a : 1 }).map( function(z){ return z.a + "-" + z.b } ).toString() );