title: Set document's rank in collection depending on score
body: <p>I have a collection of highscore documents that look like this:</p>
  
  <pre><code>{
    "data": {
      "highscores": [
        {
          "id": "58c02942f9256663764edc3d",
          "userName": "user3",
          "score": 123,
          "rank": null
        },
        {
          "id": "58c02957f9256663764edc3e",
          "userName": "user2",
          "score": 444,
          "rank": null
        },
        {
          "id": "58c02966f9256663764edc3f",
          "userName": "user1",
          "score": 64,
          "rank": null
        },
        {
          and more...
        }
      ]
    }
  }
  </code></pre>
  
  <p>And for now I'm using this line of code to display a sorted highscore list:</p>
  
  <pre><code>this.model.find({}).sort({ score: -1 }).limit(5);
  </code></pre>
  
  <p>But I want to order it by rank so I can jump to that document by the rank value (and e.g. show the next 9 documents after that). But I don't know how I can iterate through the collection and set the rank depending on user's score value. Can anyone help?</p>
  
  <p>Edit: The higher the score, the higher the rank. So in that example list user2 is first (rank 1), user3 is second (rank 2) and user1 has rank 3.</p>
  
  <p>Edit2: I am using Mongoose. There are some functions that exist in native MongoDB but not in Mongoose.</p>