title: MongoDB - how to query for a nested item inside a collection?
body: <p>I have some data that looks like this:</p>
  
  <pre><code>[
      {
          "_id" : ObjectId("4e2f2af16f1e7e4c2000000a"),
          "advertisers" : [
              {
                  "created_at" : ISODate("2011-07-26T21:02:19Z"),
                  "category" : "Infinity Pro Spin Air Brush",
                  "updated_at" : ISODate("2011-07-26T21:02:19Z"),
                  "lowered_name" : "conair",
                  "twitter_name" : "",
                  "facebook_page_url" : "",
                  "website_url" : "",
                  "user_ids" : [ ],
                  "blog_url" : "",
              },
  </code></pre>
  
  <p>and I was thinking that a query like this would give the id of the advertiser:</p>
  
  <pre><code>var start  = new Date(2011, 1, 1);
  &gt; var end  = new Date(2011, 12, 12);
  &gt; db.agencies.find( { "created_at" : {$gte : start , $lt : end} } , { _id : 1 , program_ids : 1 , advertisers { name : 1 }  } ).limit(1).toArray();
  </code></pre>
  
  <p>But my query didn't work.  Any idea how I can add the fields inside the nested elements to my list of fields I want to get?</p>
  
  <p>Thanks!</p>