title: Angular controller.js aggregate method with $group
body: <p>I'm working on mean stack application. Is it possible to use if else condition inside $group?</p>
  <p>Below is my code.</p>
  <p>I need to use if else condition inside $group to show multiple values.
  I'm having a hard time to get it done</p>
  <pre><code>exports.allSum = function(req,res) {
  
     borrower.aggregate([
  
     { $match: { $and: [ { state:req.params.state }] },
  
   },
   { 
     $group:
     { _id : {state:&quot;$state&quot;},
     sumInsured : { $sum: {$toDouble: &quot;$sumInsured&quot; }},
   
   }
   }
   ])
  
    .then((ress) =&gt; {console.log(ress)
    res.send(ress)
    });
  };
  </code></pre>