title: Get min and max value in single query in mongodb
body: <p>Considering the following Documents in "Words":</p>
  
  <pre><code>[{
    _id: 1,
    usages: 2,
    word: "Name"
  }, {
    _id: 2,
    usages: 1,
    word: "Street"
  }, {
    _id: 3,
    usages: 1,
    word: "House"
  }, {
    _id: 4,
    usages: 3,
    word: "Table"
  }, {
    _id: 5,
    usages: 3,
    word: "Bread"
  }, {
    _id: 6,
    usages: 4,
    word: "Door"
  }]
  </code></pre>
  
  <p>How can i get all the records where the number of usages is the lowest or highest? Lowest should return id 2 and 3(and their word), highest should return id 6 with its word.</p>
  
  <p>I need to aggregate this data into a random amount of lowest/highest records (50 to be exact) so it needs to be an aggregate. </p>
  
  <p>It should be a single lookup, so the min/max cannot be found using another query with $max or $min.</p>
  
  <p>The MongoDB version is 3.4.7, Mongoose version 5.0.0-rc1. Mongoose solution not requred since I can use a raw query. (It is preferred however!)</p>
  
  <p>Example:</p>
  
  <pre><code>Words.aggregate([ 
    { 
      $match: { _
        usages: { WHAT_SHOULD_I_HAVE_HERE }
      }
    }, { 
      $sample: { 
        size: 50 
      } 
    }
  ])
  </code></pre>
  
  <p>Thanks!</p>