我從未嘗試過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