title: mongodb $elemMatch
body: <p>According to mongodb doc, syntax for $elemMatch would be,</p>
  
  <pre><code>t.find( { x : { $elemMatch : { a : 1, b : { $gt : 1 } } } } )
  </code></pre>
  
  <p>I have tried and it works fine.
  The above means that, it can find if an object {a:1, b:'more than 1'} exist in the array x.</p>
  
  <p>I have a requirement, where I need to figure out, if all the objects in an array exist in the database or not.</p>
  
  <p>for example, let's say I have an array, </p>
  
  <pre><code>a=[{a:1, b:2},{a:3, b:4}, {a:5, b:6}]
  </code></pre>
  
  <p>and I need to find out if x contains all of them.</p>
  
  <p>t.find( { x : { $elemMatch : { a : {$all:[1]}, b : {$all:[2]} } } } ) and it finds out all x containing {a:1, b:2}</p>
  
  <p>But if I try, <code>t.find( { x : { $elemMatch : { a : {$all:[1,3]}, b : {$all:[2,4]} } } } )</code>, it fails. I know this is not correct. 
  Is there any way I can achieve this ?
  Ideallt, it should be, </p>
  
  <pre><code>t.find( { x : { $elemMatch : {$all:[ {a:1, b:2}, {a:3, b:4}] } } )
  </code></pre>
  
  <p>I tried, it does not work.</p>