[solved] Exception in queued task: ReferenceError: transform is not defined

Whenever I try to update one of my documents, it works but I still get this exception thrown on the server:Exception in queued task: ReferenceError: transform is not defined

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’ve transformed my publication, and it includes an observer for changed documents so I’m not sure what’s happening here:

/* 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 my document:

/* 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
        }
      });
   }
});

Note: I’m only getting the error from the server side. From the client, all seems well.

The error is just stating that the transform function which is used here:

    changed: function (newDocument, oldDocument) {
        self.changed('appointments', oldDocument._id, transform(newDocument));
    },

doesn’t exist.

1 Like

Oh wow. How on earth did I miss that? Thanks!

2 Likes