Reputation: 594
I have a Messages collection which I publish. Now I want the local collection to update only if a new message is inserted. But if any of the messages get deleted, I don't want anything to happen to the local collections. I tried this:
Meteor.publish('messages', function() {
var self = this;
Messages.find().observe({
added: function(doc) {
self.added('messages', doc._id);
}
});
self.ready();
});
This works but the actual document doesn't get send to the client. In the browser if I run Messages.find().fetch()
, I get this object back for each document:
{
_id: LocalCollection._ObjectID
__proto__: Object
}
Where am I going wrong?
Upvotes: 0
Views: 68
Reputation: 7151
You've made a small mistake in your added
function, you have to add the actual document as third parameter.
Messages.find().observe({
added: function(doc) {
self.added('messages', doc._id, doc);
}
});
Upvotes: 1