【发布时间】:2012-08-05 12:48:50
【问题描述】:
我有两个系列。 “people”与“location”连接,如下所示:
location_id = ObjectId()
db.people.insert(
{
_id : ObjectId(),
name : "Nick",
location : location_id
});
db.locations.insert(
{
_id : location_id,
city : "Cape Town"
});
我想创建一个locations 的直方图,给出每个city 中的人数。但我似乎无法使用 Mongo group 命令来做到这一点,因为它们是不同的集合。使用 map/reduce 的正确方法是什么?
【问题讨论】: