title: Mongoose - How to group by and populate?
body: <p>I use MongoDB and Mongoose as my ODM and I'm trying to make a query using <code>populate</code> and <code>group by</code> in the same statement.</p>
  
  <p>Here is my simple documents models :</p>
  
  <pre><code>var userSchema = new Schema({
      username: String
  });
  
  var messageSchema = new Schema({
      from: { type: Schema.ObjectId, ref: 'User' },
      to: { type: Schema.ObjectId, ref: 'User' },
      message: String,
      date: { type: Date, default: Date.now }
  });
  </code></pre>
  
  <p>I'm just trying to get every messages for one user, group by each users he talks with. I tried like this :</p>
  
  <pre><code>this.find({ 'to': user })
      .sort({ 'date': 1 })
      .group('from')
      .populate(['from', 'to'])
      .exec(callback);
  </code></pre>
  
  <p>But, unfortunately, my model doesn't have <code>group</code> method. Do you have any solution, to get this working ?</p>
  
  <p>Thank you.</p>