title: How to project selected fields from a document in mongoose based on conditions
body: <p>I have my document structure in this way. Where i am storing all the events based occured with timestamps. My document look like this</p>
  
  <pre><code>[
    {
      "_id": {
        "$oid": "589341cff92be305c034cb5a"
      },
      "__v": 0,
      "name": "TV",
      "switch_event": [
        {
          "timestamp": 1486186277826,
          "event_type": "on"
        },
        {
          "timestamp": 1486272677826,
          "event_type": "off"
        },
        {
          "timestamp": 1486099877826,
          "event_type": "off"
        },
        {
          "timestamp": 1486186277826,
          "event_type": "on"
        },
        {
          "timestamp": 1486272677826,
          "event_type": "off"
        },
        {
          "timestamp": 1486099877826,
          "event_type": "off"
        }
      ]
    }
  ]
  </code></pre>
  
  <p>Now while querying for this document i am interested in only the events which occured today. So after querying for this i am writing projection query like this (for testing i kept timestamp > 0, which should give all events) - </p>
  
  <pre><code>SwitchAppliance.find({_id:"589341cff92be305c034cb5a"},{
                  name:1,
                  switch_event:{$elemMatch: {
                      timestamp: {
                                  $gt:0
                      }
                  }}
           },(err,results)=&gt;{
              if(err) {console.log(err);return next({message: "Internal Server Error"});}
              return res.json(results);
          } ); 
  </code></pre>
  
  <p>But when i am getting result i am only getting one event object in the switch_event array- like this - </p>
  
  <pre><code>[
    {
      "_id": "589341cff92be305c034cb5a",
      "switch_event": [
        {
          "_id": "589567251c653a0890b8b1ef",
          "event_type": "on",
          "timestamp": 1486186277826
        }
      ],
      "name": "TV"
    }
  ]
  </code></pre>