title: How to populate resulted array of Id's with $lookup
body: <p>I am trying to find all reviews for a given item uploaded by a user. I want to display inside my user profile page a list of all his uploaded products and for each item want to display some reviews. In order to achieve this I am trying to group all reviews by item. First I am trying to do it with aggregation in order to group all reviews by item, after that, I want to populate the <b>item</b> inside the aggregation result in order to get some fields like title and rating. Also, I am trying to populate <b>reviews.user</b> as I have to get the username who wrote the review. It is not a difficult query however the syntax of $lookup stopping me from achieving this. Thanks for all the help in advance.</p>
  
  <p>I have these schemas </p>
  
  <pre><code>const reviewSchema = new Schema(
      {
              text: { type: String, max: [400, 'Too long, max is 400 characters']},
              createdAt: { type: Date, default: Date.now },
              rating : { type: Number },
              user: {type: Schema.Types.ObjectId, ref:'User'},//User who wrote review
              item: {type: Schema.Types.ObjectId, ref:'Item', default: null},// Review belongs to this item
      });
  
  const userSchema = new Schema(
      {
              username: { type: String, max: [20, 'Too long, max is 20 characters']},
              createdAt: { type: Date, default: Date.now },
              rating : { type: Number },
              email: { type: Number },
              items: [{type: Schema.Types.ObjectId, ref:'Item'}]
              // Some more info
      });
  
  
  const itemSchema = new Schema(
      {
              title: { type: String, max: [40, 'Too long, max is 40 characters']},
              rating: { type: number },
              user : {type: Schema.Types.ObjectId, ref:'User'},
              // Some more info
      });
  </code></pre>
  
  <p>I reached this far before noticing that I have to populate an array inside the aggregation pipeline.</p>
  
  <pre><code>  const resolvedItemReviews = await Promise.all(user.items.map(async (rental) =&gt;{
        return new Promise((resolve, reject) =&gt; 
        {
        Review.aggregate([
                     { "$match": {$and: [
                                         {item: item._id}, 
                                         {_id: { $nin: queryObj.seenIDs }}
                                     ]}},
                         { '$limit' : 5},
                         { "$sort": { "createdAt": 1 } },
                         { "$group": { 
                                 "_id": "$item",
                                 "item": {'$first': '$item'},
                                 "reviews": { $push: {"text": "$text","user": "$user","rating": "$rating" ,"createdAt": "$createdAt"} },
                                  }
                              },
                              // unwind source
                              {"$unwind": "$reviews"},
                              { "$lookup": {
                                  "from": "User",
                                  "localField": "reviews.user",
                                  "foreignField": "_id",
                                  "as": "reviewUser"
                              }},
                              { "$unwind": "$reviewUser" },
                          ],
                          async function(err,results) {
                              if (err) reject(err);
                              console.log(results)
  
                              await Item.populate(results, { "path": "rental", select: 'title image rating'})
                              resolve( results )
                      })
                  });
              })
  </code></pre>
  
  <p>I am currently getting this result:</p>
  
  <pre><code>[ { _id: 5c94061acd2e4e50a4e921aa,
  item: 5c94061acd2e4e50a4e921aa,
  reviews:
   { text:
      'Lorem ipsum dolor sit amet',
     user: 5c1c774ccc273b1584925b9d,
     rating: 5,
     createdAt: 2019-03-21T21:49:03.510Z } },
    { _id: 5c94061acd2e4e50a4e921aa,
  item: 5c94061acd2e4e50a4e921aa,
  reviews:
   { text:
      'Lorem ipsum dolor sit amet,',
     user: 5c5a3cb031c62708c4143f82,
     rating: 5,
     createdAt: 2019-03-21T22:10:10.013Z } } ]
  </code></pre>
  
  <p>And this would be an expected result</p>
  
  <pre><code>[ { _id: 5c940eb1c1d32b4fdc5c7ef4,
  item: {
    _id: 5c940eb1c1d32b4fdc5c7ef4
    title: "Item title text",
    rating: 4.3,
    image: "https://www.imageurl.com",
  },
  reviews:
   { text: 'Some review text',
     user: {
       username: "TestUser",
       rating: 4.6,
       image: "https://www.user-imageurl.com",
     },
     rating: 4,
     createdAt: 2019-03-21T22:23:59.105Z } 
    },
  
   { text: 'Some review text from another user',
     user: {
       username: "TestUser 2",
       rating: 3.1,
       image: "https://www.user2-imageurl.com",
     },
     rating: 3,
     createdAt: 2019-02-21T22:23:59.105Z } 
     }
   ]
  </code></pre>