2014-01-13 64 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