title: Mongoose optional search query parameters?
body: <p>I have a following situation.
  I need to build a mongoose query, based on certain arguments if present.</p>
  
  <p>I.e. if object like this is passed</p>
  
  <pre><code>{
      player: "nickname",
      action: "capture"
  }
  </code></pre>
  
  <p>the following search is performed:</p>
  
  <pre><code>Entry.find({
      player: obj.player,
      action: obj.action
  }).
      exec(function(err, res){
          console.log(res);
      });
  </code></pre>
  
  <p>If I need to exclude "action" from search if action is not in the object, what should I do?
  Using ternary operator like <code>action: (obj.action) ? obj.action:null</code> doesn't work, as would search entries in DB where <code>action</code> is <code>null</code>.</p>