title: mongo query for multiple condition
body: <p>I have data,</p>
  
  <pre><code>var data = [{name: 'n1', age: 22}, {name: 'n1', age: age: 11}, {name: 'n2', age: age: 16}, {name: 'n3', age: 22}];
  </code></pre>
  
  <p>and I want to get data according to my multiple conditions:</p>
  
  <p>condition 1:- <code>var query = {name: 'n1', age: 22};</code></p>
  
  <p>condition 2:- <code>var query = {name = '', age: 22}</code></p>
  
  <p>What I want with a single query:</p>
  
  <p>If I run condition 1 then the result should be  </p>
  
  <pre><code>[{name: 'n1', age: 22}].
  </code></pre>
  
  <p>and if I run condition 2, then the result should be </p>
  
  <pre><code>[{name: 'n1', age: 22}, {name: 'n3', age: 22} ].
  </code></pre>
  
  <p>Means for second condition, query should search only with age field.</p>
  
  <p>That all I want to implement in one query.</p>
  
  <p>I am doing like:</p>
  
  <pre><code>$query:{$and: [{name: query.name}, {age: query.age}]}
  </code></pre>
  
  <p>It works for first condition but not for second.
  How can achieve it in one query?</p>