2014-01-13 36 views

回答

5

您可以使用Aggregation Framework对用户进行分组。该查询会像:

db.users.aggregate({$group : {_id : "$uid", users : {$addToSet : "$id"}}}) 

结果会是这样的:

"result" : [ 
    { 
     "_id" : "25346346221", 
     "users" : [ 
      "[email protected]" 
     ] 
    }, 
    { 
     "_id" : "57672373683", 
     "users" : [ 
      "[email protected]", 
      "[email protected]" 
     ] 
    } 
] 
+0

这是伟大的! – Michael