我从未尝试过map/reduce。mongodb获取最古老的动物地图/缩小
我将如何获得每种动物的最古老?
我的数据是这样的:
[
{
"cateory": "animal",
"type": "cat",
"age": 4,
"id": "a"
},
{
"cateory": "animal",
"type": "bird",
"age": 3,
"id": "b"
},
{
"cateory": "animal",
"type": "cat",
"age": 7
"id": "c"
},
{
"cateory": "animal",
"type": "bird",
"age": 4,
"id": "d"
},
{
"cateory": "animal",
"type": "cat",
"age": 8,
"id": "e"
},
{
"cateory": "company",
"type": "Internet",
"age": 5,
"id": "Facebook"
}
]
我使用节点MongoDB的母语。谢谢!
如果您使用的是猫鼬用MongoDB的,这里是如何实现地图/减少https://gist.github.com/1123688 – Madhusudhan