我有一个数组array = [[53,600],[9,89],[56,9],...[4,67]]
,我有兴趣创建一个新的list
,只包含array
中每个元素的第一个条目。所以,我想要的输出是list = [53,9,56,....,4]
。我该怎么做?
答案 0 :(得分:5)
将db.getCollection('yourCollection').aggregate([
{
$unwind: {
path: "$detailLine"
}
},
{
$project: {
allowedAmount: "$detailLine.value.detailLineCharges.allowedAmount"
}
},
{
$group: {
_id: "x",
details: {
$push: "$allowedAmount"
}
}
}
])
和{
"_id" : "x",
"details" : [
{
"amount" : "11111",
"reasonCode" : "aaaah"
},
{
"amount" : "22222",
"reasonCode" : "BBBB"
}
]
}
与 SymbolToProc 一起使用:
map