새로운 오전 MongoDB 그리고 두 배에서 문서를 다음과 같다. 하고 싶어에서 특정 값을 모두 배열입니다. 예를 들어"received_bytes"그 값에서 값 배열"43118304". 나는 몇 가지 연구를 했지만 제가 생각하는도 잃었습니다.
fields:{
"time",
"received_bytes",
"sent_bytes"
}
values:{
"2021-11-22T08:08:30Z",
43118304,
43105744
}
기본적인 집계 했
return await Metric.aggregate([
{
$match: matches,
},
{ $sort: { _id: 1 } },
{
$group: {
_id: params.field, // received_bytes
values: { $push: '$values' }, // array of values for received_bytes
},
},
]);
내가 무엇을 기대:
{
_id:"received_bytes",
values:[] //all received_bytes values
}
감사합니다.