If you want this setting to work, you need to do the following:
Meteor.publish('thisNameDoesNotMatter', function () { var self = this; var handle = Meteor.users.find({}, { fields: {emails: 1, profile: 1} }).observeChanges({ added: function (id, fields) { self.added('thisNameMatters', id, fields); }, changed: function (id, fields) { self.changed('thisNameMatters', id, fields); }, removed: function (id) { self.removed('thisNameMatters', id); } }); self.ready(); self.onStop(function () { handle.stop(); }); });
No on the client side you need to define a collection on the client side:
directories = new Meteor.Collection('thisNameMatters');
and subscribe to the appropriate data set:
Meteor.subscribe('thisNameDoesNotMatter');
This should work now. Let me know if you think this explanation is not clear enough.
EDIT
Here, the self.added/changed/removed methods act more or less like an event dispatcher. In short, they give instructions to every customer who called
Meteor.subscribe('thisNameDoesNotMatter');
about updates that should be applied to a collection of clients named thisNameMatters , assuming that this collection exists. The name passed as the first parameter can be chosen almost arbitrarily, but if there is no corresponding collection on the client side, all updates will be ignored. Please note that this collection can only be client-side, therefore it does not have to correspond to the "real" collection in your database.
Returning the cursor from the publish method, this is just a shortcut to the above code, with the only difference being that theNameMatters name of the actual collection is used theNameMatters the actual collection. This mechanism actually allows you to create as many “mirrors” of your data sets as you like. In some situations, this can be very useful. The only problem is that these “collections” will be read-only (which is completely pointless to BTW), because if they are not defined on the server, the corresponding `insert / update / remove 'methods do not exist.