给定以下文档结构:
{
_id: "abc123",
name: "Some name",
properties: [
{
definition: "temp",
values: [
{
created: 1376061128,
value: 82
},
{
created: 1376062368,
value: 85
},
{
created: 1376062627,
value: 88
}
]
},
{
definition: "alert",
values: [
{
created: 1376061128,
value: 0
},
{
created: 1376062368,
value: 1
},
{
created: 1376062627,
value: 0
}
]
}
]
}
我希望能够返回一个文档,其中每个属性只有“最新”(基于创建的)值,如下所示:
{
_id: "abc123",
name: "Some name",
properties: [
{
definition: "temp",
values: [
created: 1376062627,
value: 88
]
},
{
definition: "alert",
values: [
created: 1376062627,
value: 0
]
}
]
}
一般来说,我在处理 MongoDB 和 map/reduce 方面相当陌生,所以我不确定我应该关注什么方向。这是一个新的数据模型,所以如果有关于修改文档模型的建议,我也愿意倾听。