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:
db.collection.aggregate([
{
$project: {
_id: 0,
results: {
$map: {
input: {
$filter: {
input: {
"$objectToArray": "$$ROOT"
},
cond: {
$ne: [
"$$this.k",
"_id"
]
}
}
},
in: "$$this.v"
}
}
}
}
])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.