title: Find documents matching multiple fields in an object array in MongoDB
body: <p>Let's say I have an array of objects (let us call that array A) and I need a query to find a collection in MongoDB for all documents matching one of it's fields to one of the properties of object 1 in array A and another field to some other property in the same object in array A.</p>
  
  <p>The documents do not have all the properties that the objects in array A have.</p>
  
  <p>To make things clear...</p>
  
  <p>Array A would look something like this...</p>
  
  <pre><code>[{
      id_bus:1,
      id_bus_variation:13,
      ....
  },{
      id_bus:2,
      id_bus_variation:184,
      ....
  },{
      id_bus:3,
      id_bus_variation:13,
      ....
  }]
  </code></pre>
  
  <p>The documents in my database include those two properties and I need to match those two at the same time. For example, I need to find in my database the docs that have <code>id_bus == 1</code> and <code>id_bus_variation == 13</code>, and also the ones that have <code>id_bus == 2</code> and <code>id_bus_variation == 184</code> but not the ones that <code>id_bus == 4</code> and <code>id_bus_variation == 13</code>.</p>
  
  <p>I really don't have any idea of how to do this using a single query, the only way around it I found is to go through array A and execute a query for each of it's elements, matching all the fields I need, but that doesn't seem efficient.</p>