I'm trying to transform a publication, and this is my code:
Meteor.publish('appointments.waiting', function () {
var self = this,
count = 0;
Appointments.find().forEach(function (appointment) {
var patients = Patients.find({_id: appointment.patient_id}).fetch();
var first_name = patients[count].profile.first_name,
middle_name = patients[count].profile.middle_name,
surname = patients[count].profile.surname,
name = surname + ', ' + first_name + ' ' + middle_name;
self.added('appointments', appointment.names, name);
});
self.ready();
});
When I console.log(name)
, I can see the name in full but I'm not quite sure how to use this.added
to add the new data. How do I go about this? And if I do enter this new data, will it overwrite the older data?
If there's a better way to achieve this, I'd also like to know.