我将以下数据存储在集合“订单”中 data in collection
我必须找到状态为F的每个客户的最大数量
我尝试了以下操作,但答案错误
> var mapfunction =function(){if(this.status=='F') emit(this.cus_id,this.amount);}
> var reducefunction=function(key,value){return Math.max(...value);}
> db.Order.mapReduce(mapfunction,reducefunction,{out:'total7'})
{
"result" : "total7",
"timeMillis" : 528,
"counts" : {
"input" : 6,
"emit" : 2,
"reduce" : 0,
"output" : 2
},
"ok" : 1
}
> db.total7.find()
{ "_id" : "A1", "value" : 200 }
{ "_id" : "C1", "value" : 200 }