[英]Show the output in an array of values
Hello I have this query result你好我有这个查询结果
{
sac: 1,
sac_db: 0,
kafka: 1,
platform: 13700,
}
now I just want to show the values in an array, but I can't find how to do it:现在我只想显示数组中的值,但我找不到如何做到这一点:
[1,0,1,13700]
You can get this done using $map
and $objectToArray
, like so:您可以使用
$map
和$objectToArray
完成此操作,如下所示:
db.collection.aggregate([
{
$project: {
_id: 0,
results: {
$map: {
input: {
$filter: {
input: {
"$objectToArray": "$$ROOT"
},
cond: {
$ne: [
"$$this.k",
"_id"
]
}
}
},
in: "$$this.v"
}
}
}
}
])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.