title: Mongodb how can I query a subset of an array for a specific document
body: <p>I want to run a query to select specific documents.  Then on each document, open up an array of sub documents and run a query to filter those sub docs.</p>
  
  <p>Example:</p>
  
  <pre><code>{
    "_id" : ObjectID(23412351346435),
    "list" : [
      {date: ISODate(2015-01-12T00:00:00.000Z), name: "Jan 12"},
      {date: ISODate(2015-01-13T00:00:00.000Z), name: "Jan 13"},
      {date: ISODate(2015-01-14T00:00:00.000Z), name: "Jan 14"}
    ]
  }
  </code></pre>
  
  <p>I'm guessing I can do something with Mongo's <code>aggregate</code> function.  I have been able to match the documents I want, but how can I get a sub query going on the array?  I tried using <code>$elemMatch</code> but that only returns the first item in the array that matches the date range.</p>
  
  <p>To be clear when I query for <code>ObjectID(23412351346435)</code> and Date range 2015-01-12 to 2015-01-13 I want it to return this;</p>
  
  <pre><code>{
     "_id" : ObjectID(23412351346435),
     "list" : [
          {date: ISODate(2015-01-12T00:00:00.000Z), name: "Jan 12"},
          {date: ISODate(2015-01-13T00:00:00.000Z), name: "Jan 13"}
     ]
  }
  </code></pre>