我有一个这种格式的文件
{
"_id" : ObjectId("5c488e688e0dbe41183a22b7"),
"id" : "d400003",
"orderBC" : "20190123_165230",
"orderTS" : 1548258750000.0,
"value" : 1
}
我希望获得最终结果
{
"id": "d400003",
"data": [ 15482587500000 , 1]
}
答案 0 :(得分:1)
您需要$project,请尝试以下汇总:
db.col.aggregate([
{
$project: {
_id: 0,
id: 1,
data: [ "$orderTS", "$value" ]
}
}
])