title: How to retrieve the bucket boundaries when using mongo's $bucket aggregation?
body: <p>I have a collection of 200,000+ records which include a float field <code>amountAwarded</code> (eg. 12345.67, 2342, 22 etc). I'm using MongoDB to aggregate these into buckets based on the following boundaries:</p>
  
  <pre><code>amountAwarded: [
          {
              $bucket: {
                  groupBy: '$amountAwarded',
                  boundaries: [0, 10000, 50000, 100000, 1000000, Infinity],
                  output: {
                      count: { $sum: 1 }
                  }
              }
          }
      ]
  </code></pre>
  
  <p>This works as expected and I get this output:</p>
  
  <pre><code>{
    "amountAwarded": [
      {
        _id: 0,
        count: 269
      },
      {
        _id: 10000,
        count: 67
      },
      // etc
    ]
  }
  </code></pre>
  
  <p>What I really want is to reference the bucket boundaries in the output, eg:</p>
  
  <pre><code>{
    "amountAwarded": [
      {
        _id: 0,
        count: 269,
        lowerBound: 0,
        upperBound: 9999
      }
    ]
  }
  </code></pre>
  
  <p>This means I can construct a list on the frontend showing the buckets (eg. <code>£0 - £9999</code>).</p>
  
  <p>The closest I've come is adding <code>$min: "$amountAwarded"</code> (and an equivalent <code>$max</code>) to the <code>output</code>, which gives me the upper/lower values for that field in the bucketed records. This isn't right though as the numbers are obviously from the data (eg. <code>8762</code>) rather than the bucket bounds.</p>
  
  <p>Is it possible to refer to the matched bucket boundaries inside the aggregation pipeline, or will I have to construct this manually after the facet is complete?</p>