title: Max and min in mongodb
body: <p>I have the a collection of entries as follows:</p>
  <pre><code>{
    company:&quot;C3&quot;,
    model:&quot;M3&quot;,
    price:55600,
    discount:9,
    ...
  }
  </code></pre>
  <p>and there are more than 2000 entries.</p>
  <p>I am trying to find out <code>max</code> <strong>and</strong> <code>min</code> prices in the whole collection.</p>
  <p>Maybe with something along the lines of:</p>
  <pre><code>db.collection.find({ max: { $max: &quot;$price&quot; }, min: { $min: &quot;$price&quot; } });
  </code></pre>
  <p>I'd like the output as <code>{ max: 2000, min: 5000 }</code>.</p>