title: MongoDB filter duplicate users from result
body: <p>I have a mongo collection with activities in this format:</p>
  
  <pre><code>{
    "_id": 1,
    "user": 1,
    "time": 12345,
    "data": ...
  }
  </code></pre>
  
  <p>Now I want to get the 5 latest entries (the whole entry) from this collection but I want only one entry for each user in the case there are more than one activities from a user in the latest activities. I do not want to filter the result after the DB query. I hope there is a mongoDB way to do this on the DB server.</p>
  
  <p>I would like to perform this query with Doctrine MongoDB ODM but I suspect that this is not possible with the provided methods. But a direct mongo query is fine too.</p>