title: select collection and get the last item of each in other collection in MongoDB
body: <p>I subscribed to the publication with the code below. So in my server side file,</p>
  
  <pre><code>Meteor.publish('people', function() {
      cursor = EmailDB.find({category:{$ne:"Spammer"}},{sort:{"lastMessage.date": -1},limit:20});
          let transformData = (fields) =&gt; {
                  // this is the person we're processing now
                  let eadd = fields.eadd;
  
                  // get the latest message for this person
                  key.eadd = eadd;
                  let lastMessage = MessageDB.findOne(key,
                      {
                          sort: {date: -1}
                      }
                  );
  
                  // add his last message to the returned data
                  fields.lastMessage = lastMessage;
  
                  return fields;
              };
  
              let handle = cursor.observeChanges({
                  added: (id, fields) =&gt; {
                  fields = transformData(fields);
              this.added('emails', id, fields);
          },
              changed: (id, fields) =&gt; {
                  fields = transformData(fields);
                  this.changed('emails', id, fields);
              },
              removed: (id) =&gt; {
                  this.removed('emails', id);
              }
          });
  
              this.ready();
  
              this.onStop(() =&gt; {
                  handle.stop();
          });
          return cursor;
  }
  </code></pre>
  
  <p>It get all the records of Person.
  I want to get the latest message of each person.
  So I used the code above but it is not working, It does not add additional fields to my query.</p>
  
  <p>I need to just subscribe and fetch all records, and in each record there must be a last message. </p>