summaryrefslogtreecommitdiff
path: root/jstests/find1.js
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-01-26 23:28:26 -0500
committerEliot Horowitz <eliot@10gen.com>2009-01-26 23:28:26 -0500
commitbc38646deb39f5d5af3cd33e34f49b596e837401 (patch)
tree33affd5a1fedb7f8cfad044d92c262d12158ff8b /jstests/find1.js
parentf235a0f1b1a8ad6fbbce046205d4b78e60bc1df8 (diff)
downloadmongo-bc38646deb39f5d5af3cd33e34f49b596e837401.tar.gz
imported tests
Diffstat (limited to 'jstests/find1.js')
-rw-r--r--jstests/find1.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/jstests/find1.js b/jstests/find1.js
new file mode 100644
index 00000000000..140406c6b15
--- /dev/null
+++ b/jstests/find1.js
@@ -0,0 +1,23 @@
+db = connect( "test" );
+t = db.find1;
+t.drop();
+
+t.save( { a : 1 , b : "hi" } );
+t.save( { a : 2 , b : "hi" } );
+
+assert( t.findOne( { a : 1 } ).b != null , "A" );
+assert( t.findOne( { a : 1 } , { a : 1 } ).b == null , "B");
+
+assert( t.find( { a : 1 } )[0].b != null , "C" );
+assert( t.find( { a : 1 } , { a : 1 } )[0].b == null , "D" );
+
+id = t.findOne()._id;
+
+assert( t.findOne( id ) , "E" );
+assert( t.findOne( id ).a , "F" );
+assert( t.findOne( id ).b , "G" );
+
+assert( t.findOne( id , { a : 1 } ).a , "H" );
+assert( ! t.findOne( id , { a : 1 } ).b ), "I" ;
+
+assert(t.validate().valid);