2015-05-21 172 views
1

我的收藏是這樣的:有scoreasc 如何在MongoDB中執行組合,排序和限制聚合?

    1. group與關鍵batchyearlocation
    2. sort得到top 10id, year, batch, location, score的每個:

      "_id": ObjectId(""), 
      "score": 500, 
      "year": 2015, 
      "batch": 1 
      "location": "Shenzhen" 
      

      我在做什麼是這個組

  • +0

    哪裏是在您的文檔的位置? –

    +0

    @dev這是我的能力,我很想念這個 – roger

    回答

    -2

    使用聚合框架:

    db.collection.aggregate(
        {$group:{...}}, 
        {$sort:{...}}) 
        {$limit: 10} 
    );