title: How to query mongodb from a search form using node and express
body: <p>I want to make an HTML form to query MongoDB.  How can I write the logic to ignore blank fields?  For example, I have two search parameters.  If the lastname field is blank, how would I write the query to ignore that field?</p>
  
  <pre><code>router.post('/auth/search', auth, function(req,res){
      var db = req.db;
      console.log(req.body);
      db.users.find({ 'firstname': req.body.firstname,
                      'lastname' :req.body.lastname  // if this field is blank in the form how can I ignore it?
  
      }, function(err, docs){
          if (err) return err;
          console.log(docs);
          res.send(docs);
      });
  });
  </code></pre>
  
  <p>Appreciate any help.  Thanks!</p>