mongodb function from rails
问题 I use mongomapper with mongodb for rails models. In the mongodb I have this function db.system.js.save({_id:'resumenTemporada',value:function(collection, condition){ var res= db[collection].group({ key:{}, reduce:function(obj,prev){ prev.ppa += obj.precipitation; if( obj.temperature < 5 && obj.temperature >0) prev.hf += obj.temperature/4; }, initial : {ppa:0,hf:0}, cond: condition}); return res ; } }); And get this output > db.eval("return resumenTemporada('stations',{nombre:'pua',fecha:{$gt: