diff options
Diffstat (limited to 'jstests/eval1.js')
-rw-r--r-- | jstests/eval1.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/jstests/eval1.js b/jstests/eval1.js new file mode 100644 index 00000000000..4c5fe3d283f --- /dev/null +++ b/jstests/eval1.js @@ -0,0 +1,16 @@ + +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 ) ); |