title: Query for set of records given a month/year (NOT ISO DATE)
body: <p>I'm trying to pass unique dates of n (lets say 2000+ records) to frontend, give users a list of <code>mm/yyyy</code> to choose the records by month. </p>
  
  <p>Then I need it pass their selected month as the ID (currently format of <code>mm-yyyy</code>) to backend, and then query for only that set of records in that month/year.</p>
  
  <p>I was able to get all distinct months/years for all records. But now I need to pass the <code>month/year</code> as a parameter. </p>
  
  <p><strong>My question is:</strong> How can I query for all records that match a given month/year?</p>
  
  <p>I posted about something <a href="https://stackoverflow.com/questions/33109897/get-distinct-iso-dates-by-days-months-year/33110212?noredirect=1#comment54037111_33110212">similar</a> earlier, where user3100115 recommended using <a href="http://docs.mongodb.org/manual/reference/operator/aggregation/redact/" rel="nofollow noreferrer">$redact</a>. </p>
  
  <p>Docs say to pass in a year, <code>{ $match: { year: 2014 } },</code> and I'm assuming you can do this with month too. But then didn't really understand the "redact" portion of it.</p>
  
  <p>So I just tried getting all records using the $match and year:</p>
  
  <p><code>db.mycollection.aggregate( { $match: { year: 2015 } } );</code> which returned nothing because I don't have a simple <code>year</code> field in my document... rather a <code>date</code> with format ISO.</p>
  
  <hr>
  
  <p>I've tried </p>
  
  <pre><code>    var query = Order.aggregate(
          {
              $project:
              {
                  year :
                  {
                      $year:  '$date'
                  },
                  month:
                  {
                      $month: '$date'
                  }
              }
          },
          {
              $match:
              {
                  year : year,
                  month: month
              }
          }
      );
  </code></pre>
  
  <p>But this doesn't return the document objects, only the _id, month, year:</p>
  
  <pre><code>  { _id: 'someid',
      year: 2015,
      month: 3 },
    { _id: 'someid',
      year: 2015,
      month: 3 },
  </code></pre>