title: Find query in mongodb using cases
body: <p>I have a collection of product in which I have document like this</p>
  
  <pre><code>"_id" : ObjectId("5acb1dad698eaa7a254c9017"),
  "txtProductCode" : "1233A",
  "txtModelCode" : "00M",
  "txtPartNo" : "00P",
  "txtSerialNo" : "00S",
  "txtProductName" : "Watch",
  "traderId" : ObjectId("5ac5fb29b0f9b3444e6c1ef2")
  </code></pre>
  
  <p>I want to search a product based on its name and traderId for which I used</p>
  
  <pre><code>db.getCollection('product').find( {$and:[{'txtProductName':"Watch"},{"traderId" : ObjectId("5ac5fb29b0f9b3444e6c1ef2")}]})
  </code></pre>
  
  <p>its working fine but now if a user have input model no then it shoud use model number also to search for a product if the user have not input the model no then it should without model number</p>
  
  <p>So My question is do I have to use cases like this</p>
  
  <pre><code>if(req.body.modelNo)
      db.getCollection('product').find( {$and:[{'txtProductName':"Watch"},{"traderId" : ObjectId("5ac5fb29b0f9b3444e6c1ef2")},{'txtModelCode':"00M"}]})
  else
    db.getCollection('product').find( {$and:[{'txtProductName':"Watch"},{"traderId" : ObjectId("5ac5fb29b0f9b3444e6c1ef2")}]})
  </code></pre>
  
  <p>or is there a way to do this without making cases I have to do this for multiple condtions so I am trying not to use cases</p>