summaryrefslogtreecommitdiff
path: root/jstests/eval1.js
blob: 4a5ca75f09bb3337a8baff327ee324ae4e8d65a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

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 ) , "A" );
assert.eq( "sara" , f( 2 ) , "B" );
assert.eq( "eliot" , db.eval( f , 1 ) , "C" );
assert.eq( "sara" , db.eval( f , 2 ) , "D" );