title: How should I find a Mongoose subdocument given the parent document and a value in the subdocument?
body: <p>I'm just trying to do a basic find similar to <code>.findOne</code>, but on a subdocument array in Mongoose. Should I simply loop through the array looking for the right subdocument?</p>
  
  <p>I have a schema like so:</p>
  
  <pre><code>var RegionSchema = new Schema({
    "metadata": {
      "regionType": String,
      "name": String,
      "children": [{
        "name": String,
        "childType": String
      }],
      "parent": Schema.ObjectId
    },
  
    "data": [DataContainer]
  });
  </code></pre>
  
  <p>I know that I want to find a <code>DataContainer</code> in <code>data</code> with <code>dataYear</code> equal to <code>"2014"</code>. I'm new to MongoDB, so I don't know many advanced commands. What would be the most efficient way?</p>
  
  <p>EDIT: <code>dataYear</code> is guaranteed to be unique in that array.</p>