title: Return Latest Sorted Date from Multiple Arrays
body: <p>I currently have this schema</p>
  
  <pre><code>var dataSchema = new Schema({
  hid: { type: String },
  sensors: [{
      nid: { type: String },
      sid: { type: String },
      data: {
          param1: { type: String },
          param2: { type: String },
          data: { type: String }
      },
      date: { type: Date, default: Date.now }
  }],
  actuators: [{
      nid: { type: String },
      aid: { type: String },
      control_id: { type: String },
      data: {
          param1: { type: String },
          param2: { type: String },
          data: { type: String }
      },
      date: { type: Date, default: Date.now }
  }],
  status: [{
      nid: {type: String},
      status_code: {type: String},
      date: { type: Date, default: Date.now }
  }],
  updated: { type: Date, default: Date.now },
  created: { type: Date }
  });
  </code></pre>
  
  <p>And the query that I'm trying to build should search the schema by "hid" and then only pick the last object (by date) from the "sensors", "actuators" and "status" arrays but I can't figure out how to do that.</p>
  
  <p>With this query I can partially achieve what I'm trying to get but it only give me one array at the time so I have to query the database three times and I would avoid doing so</p>
  
  <pre><code>db.getCollection('data').aggregate([
                      { $match : { hid : "testhid" } },
                      {$project : {"sensors" : 1}},
                      {$unwind : "$sensors"},
                      {$sort : {"sensors.date" : -1}},
                      {$limit : 1}
                  ])
  </code></pre>
  
  <p>Thanks in advance for any help</p>