title: How to round a value in mongodb aggregation
body: <p>I have function which calculate min, max and mean of given date range from db collection. I need the min, max and mean but as rounded values.</p>
  
  <p><strong>Sample Doc :</strong></p>
  
  <pre><code> {
      maxspeed: 27.264,
      minspeed: 11.5,
      meanspeed: 14.407407407
   }
  </code></pre>
  
  <p><strong>Code :</strong></p>
  
  <pre><code>exports.findspeedminmaxmean = (req, res) =&gt; {
      var a=req.query.osm_start_node_id;
      var b= req.query.osm_end_node_id;
      var date1=req.query.utc_timestamp;
      var num1=parseInt(a);
      var num2=parseInt(b);
       console.log(a);
  
      speeddata.aggregate([{ $match: { 'osm_start_node_id': num1,'osm_end_node_id':num2,'utc_timestamp':{$gte:date1[0],$lte:date1[1]}}},
      {$group:{_id:"$osm_start_node_id",_id:"$osm_end_node_id",maxspeed:{$max:"$speed_mph_mean"},
      minspeed:{$min:"$speed_mph_mean"},
      meanspeed:{$avg:"$speed_mph_mean"}}}])
    .then(stable =&gt; {
        if(!stable) {
            return res.status(404).send({
                message: "record not found " + req.query.osm_way_id
            });            
        }
        res.send(stable);
        console.log(stable);
    }).catch(err =&gt; {
        if(err.kind === 'osm_way_id') {
            return res.status(404).send({
                message: "record not found " + req.query.osm_way_id
            });                
        }
        return res.status(500).send({
            message: "something wrong with name " + req.query.osm_way_id
        });
    });
   };
  </code></pre>