0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/jstests/find1.js
2009-01-31 17:22:22 -05:00

23 lines
567 B
JavaScript

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);