title: Ignoring NULL values within an aggregate operation in MongoDB
body: <p>I have the following MongoDB aggregate operation which is working fine but it also seems to be returning NULL values.</p>
  
  <p>How can I ignore NULL values against projectIP field?</p>
  
  <pre><code>db.inventory.aggregate(
      [
       { $match:   {projectIP: { $exists:true }}},
       { $project: {projectIP: "$projectIP",_id : 0}},
       { $group:   {_id: "$projectIP"}},
       { $sort:    {projectIP: 1}}
      ];
  )
  </code></pre>