0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/jstests/eval1.js
2009-02-15 16:12:54 -05:00

17 lines
324 B
JavaScript

t = db.eval1;
t.drop();
t.save( { _id : 1 , name : "eliot" } );
t.save( { _id : 2 , name : "sara" } );
f = function(id){
return db["eval1"].findOne( { _id : id } ).name;
}
assert.eq( "eliot" , f( 1 ) );
assert.eq( "sara" , f( 2 ) );
assert.eq( "eliot" , db.eval( f , 1 ) );
assert.eq( "sara" , db.eval( f , 2 ) );