Now this may seem odd of my to say this, but for some reason my observers are not working properly
I am trying to track when a document is updated either via the client or the server using either observe
or observeChanges
. However if a document is updated via the client using say
Tickets.update({ _id: 'kQXeksu5rgzR5ZBJW' }, { $set: { 'status': 'unread' } });
I am seeing a result from added
not changed
and if I update the collection via the server with say
Meteor.call('markTicketAsRead', "kQXeksu5rgzR5ZBJW", function (err, res) {
console.log(err, res);
});
I am not getting any observed changes.
Tickets.find({ 'status' : 'unread' }).observeChanges({
added : function (id, doc) {
console.log(id, doc);
if(ready && typeof id === 'String' && notify.permissionLevel() === notify.PERMISSION_GRANTED) {
notify.createNotification('New Support Ticket', {
body: '#' + id,
icon: 'https://s3.amazonaws.com/assets/logo.jpg'
});
}
},
changed : function (id, fields) {
console.log("CHANGE: ", id, fields);
notify.createNotification('Support Ticket Updated', {
body: '#' + id._id + ' status ' + fields.status,
icon: 'https://s3.amazonaws.com/assets/logo.jpg'
});
}
});
});
also as a side note does anyone know how to observe changes after the initial init of a client collection meaning let it populate with the initial data and then observe the changes to it from then on out?