【发布时间】:2020-10-07 03:21:30
【问题描述】:
mongodb数据库中的数据结构如下:
{
"date": "20201005",
"data":[
[10, 20, 30, 40, 50],
[60, 70, 80, 90, 10],
[11, 12, 13, 14, 15]
]
}
{
"date": "20201006",
"data":[
[12, 22, 32, 42, 52],
[61, 77, 88, 98, 10],
[11, 12, 13, 14, 15]
]
}
{
"date": "20201007",
"data":[
[11, 21, 31, 41, 51],
[16, 17, 18, 19, 10],
[11, 12, 13, 14, 99]
]
}
并且你想在每个文档中找到数组内部数组的最大值,我想要得到的结果如下:
{"max": 99} // 99 can be find in document where "date"="20201007"
您如何使用 $max 运算符来做到这一点?
【问题讨论】:
标签: mongodb aggregation-framework aggregation