title: mongoDB (in nodeJS) aggregation pipleine returns empty array
body: <p>I'm following Jonas Schmeddtman Node.js course and building a tour App. For some reason, when I send a request using postman on the route upon which this function is called, it returns an empty array instead of the manipulated data.</p>
  <p>Below is my complete code. Thanks in advance.</p>
  <pre class="lang-js prettyprint-override"><code>      exports.getTourStats=async(req,res)=&gt;
        {
          try
          {
            const stats= await Tour.aggregate([
              {
                $match: { ratingsAverage: { $gte: 4.5 } }
              },
              {
                $group:
                {
                  _id: { $toUpper: '$difficulty' },
                        numTours: { $sum: 1 },
                        numRatings: { $sum: '$ratingsQuantity' },
                        avgRating: { $avg: '$ratingsAverage' },
                        avgPrice: { $avg: '$price' },
                        minPrice: { $min: '$price' },
                        maxPrice: { $max: '$price' }
                }
               
              }
            ]);
            
            res.status(200).json(
              {
                status:&quot;success&quot;,
                data:
                {
                  stats
                }
              });
          }
          catch(error)
          {
            res.status(400).json(
              {
                status:&quot;failed!&quot;,
                message:error
              })
          }
        }
  </code></pre>
  <p>//an example document is as below.</p>
  <pre><code>    &quot;id&quot;: 8,
      &quot;name&quot;: &quot;The Northern Lights&quot;,
      &quot;duration&quot;: 3,
      &quot;maxGroupSize&quot;: 12,
      &quot;difficulty&quot;: &quot;easy&quot;,
      &quot;ratingsAverage&quot;: 4.9,
      &quot;ratingsQuantity&quot;: 33,
      &quot;price&quot;: 1497,
      &quot;summary&quot;: &quot;Enjoy the Northern Lights in one of the best places in the world&quot;,
      &quot;description&quot;: &quot;dummy description&quot;,
      &quot;imageCover&quot;: &quot;tour-9-cover.jpg&quot;,
      &quot;images&quot;: [&quot;tour-9-1.jpg&quot;, &quot;tour-9-2.jpg&quot;, &quot;tour-9-3.jpg&quot;],
      &quot;startDates&quot;: [&quot;2021-12-16,10:00&quot;, &quot;2022-01-16,10:00&quot;, &quot;2022-12-12,10:00&quot;]
  </code></pre>
  <hr />
  <p>// schema.</p>
  <pre><code>const tourSchema = new mongoose.Schema({
    name: {
      type: String,
      required: [true, 'A tour must have a name'],
      unique: true,
    },
    duration: {
      type: Number,
      required: [true, 'a tour must have a duaration'],
    },
    maxGroupSize: {
      type: Number,
      required: [true, 'a tour must have a max group size'],
    },
    difficulty: {
      type: String,
      required: [true, 'a tour must have a diffculty'],
    },
    ratingAverage: {
      type: Number,
      default: 4.5,
    },
    ratingQuantity: {
      type: Number,
      default: 0,
    },
    price: {
      type: Number,
      required: [true, 'A tour must have a price'],
    },
    priceDiscount: {
      type: Number,
    },
    summary: {
      type: String,
      trim: true,
      required: [true, 'A tour must have a summary'],
    },
    description: {
      type: String,
      trim: true,
    },
    imageCover: {
      type: String,
      required: [true, 'A tour must have an image cover'],
    },
    images: [String],
    createdAt: {
      type: Date,
      default: Date.now(),
      //to exclude the created at property from response sent back to user we put select property to false.
      select: false,
    },
    startDates: [Date],
  });
  //creating a model out of the schema we defined.
  const Tour = mongoose.model('Tour', tourSchema);
  module.exports = Tour;
  </code></pre>