-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。謝謝 –