title: MongoDB - Returning only matching Array from Object
body: <p>i have the following document in a collection:</p>
  
  <pre><code>{
      "_id" : 101,
      "students" : [ 
          {
              "name" : "john",            
              "age" : 10,
              "city":'CA'
          },
          {
              "name" : "danial",            
              "age" : 15,
              "city":'KA'
          }
      ]
  }
  
  {
      "_id" : 102,
      "students" : [ 
          {
              "name" : "adam",            
              "age" : 20,
              "city":'NY'
          },
          {
              "name" : "johnson",            
              "age" : 12,
              "city":'CA'
          }
      ]
  }
  </code></pre>
  
  <p>And i fire the following query: </p>
  
  <pre><code>db.data.find({'students.city':'CA'})
  </code></pre>
  
  <p>This returns me "students" objects from both the documents, as one instance matches the filter ("city"; 'CA') in both.</p>
  
  <p>However, i desire to only get the matching array in the result. That is, i want the following result:</p>
  
  <pre><code>{
      "_id" : 101,
      "students" : [ 
          {
              "name" : "john",            
              "age" : 10,
              "city":'CA'
          }
      ]
  }
  
  {
      "_id" : 102,
      "students" : [        
          {
              "name" : "johnson",            
              "age" : 12,
              "city":'CA'
          }
      ]
  }
  </code></pre>
  
  <p>Please help.</p>