As much as the publish is working, I keep getting this error in the console whenever I try to update a document:
I20160828-23:46:59.384(3)? Exception in queued task: ReferenceError: transform is not defined
I20160828-23:46:59.389(3)? at Object.changed (server/publications/appointments-publications.js:11:59)
I20160828-23:46:59.394(3)? at [object Object].observeChangesCallbacks.changed (packages/minimongo/observe.js:162:1)
I20160828-23:46:59.397(3)? at self.applyChange.changed (packages/minimongo/observe.js:66:1)
I20160828-23:46:59.400(3)? at packages/mongo/observe_multiplex.js:183:30
I20160828-23:46:59.402(3)? at Array.forEach (native)
I20160828-23:46:59.405(3)? at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
I20160828-23:46:59.408(3)? at Object.task (packages/mongo/observe_multiplex.js:177:9)
I20160828-23:46:59.411(3)? at [object Object]._.extend._run (packages/meteor/fiber_helpers.js:147:1)
I20160828-23:46:59.415(3)? at packages/meteor/fiber_helpers.js:125:1
I updated my pub to look like this:
/* appointments-publications.js */
Meteor.publish('appointments.waiting', function () {
// Transforming data in a collection
var self = this;
var observer = Appointments.find({status: 'Waiting'}).observe({
added: function (document) {
self.added('appointments', document._id, transformAppointments (document));
},
changed: function (newDocument, oldDocument) {
self.changed('appointments', oldDocument._id, transform(newDocument));
},
removed: function (oldDocument) {
self.removed('appointments', oldDocument._id);
}
});
self.onStop(function () {
observer.stop();
});
self.ready();
});
And this is how I update:
/* appointments.js */
Meteor.call('UpdateAppointment', {
_id: appointmentId,
patient_id: patientId,
status: status,
booked: booked
}, function (error, result) {
if (error) return console.log('Error: ' + error.error);
});
/* methods.js */
Meteor.methods({
'UpdateAppointment': function (data) {
check(data, {
_id: String,
patient_id: String,
status: String,
booked: Boolean
});
return Appointments.update(data._id, {
$set: {
patient_id: data.patient_id,
status: data.status,
booked: data.booked
}
});
}
});
Do you, by any chance, know what’s happening here?