-1
使用许多条件我有一个交易集合为:如何在总蒙戈DB
{
_id:ObjecId("5286f7c1f873cc89108b6898"),
type:"sms",
amount:NumberInt(1000),
input_vendor:"a"
},
{
_id:ObjecId("5286f7c1f873cc89108b6898"),
type:"sms",
amount:NumberInt(2000),
input_vendor:"a"
},
{
_id:ObjecId("5286f7c1f873cc89108b6898"),
type:"sms",
amount:NumberInt(5000),
input_vendor:"b"
}
我想用骨料在蒙戈来算总的短信,和总量每条短信类型,请帮助我。 结果为:
total_sms_a:2
amount_sms_a:3000
total_sms_b:1,
amount_sms_b:500
如果使用你的聚合表达式,你只能得到总的短信,但我想用每个input_vendor计数:'a'和input_vedor:'b',例如:with input_vendor:a,total:2,amount:3000,和input_vendor:'b',总数:1,帐户:5000。谢谢 –