这是我从mongodb聚合得到的结果。
"result" : [
{
"_id" : {
"date" : "2013-07-01",
"ncs" : "subscription",
},
"traffic" : 1
}
]
但我需要获得如下的数据
{
"date" : "2013-07-01",
"ncs" : "subscription",
"traffic" : 1
}
有没有办法通过 $ project 来实现这个目标?
答案 0 :(得分:0)
是的,你可以试试这个:
{$ project:{" _id":0," date":" $ _ id.date"," ncs":& #34; $ _ id.ncs","流量":1}}