Meteor: Publishing all user not working without autopublish package -
i show list of users, in template. have:
//publications.js meteor.publish('users', function() { return meteor.users.find({}, { fields: {username: 1, profile: 1} }); }); //router.js router.route('/users/add/:_id?', {name: 'users.add', controller: 'useraddcontroller'}); useraddcontroller = routecontroller.extend({ subscriptions: function(){ return [ meteor.subscribe('hospitals'), meteor.subscribe('roles'), meteor.subscribe('users') ]; }, action: function() { this.render('adduser', { data: function(){ return { hospital_id : this.params._id } } }); } }); //client template.listusers.helpers({ users: function() { return meteor.users.find({}); } });
but list keep showing current logged-in user. have created list of users using account.createuser()
function doing wrong?
thanks.
you have subscribe publication using this.subscribe() in subscriptions
hook:
// place put subscriptions subscriptions: function() { this.subscribe('items'); // add subscription waitlist this.subscribe('item', this.params._id).wait(); }
or use waiton:
// subscriptions or other things want "wait" on. // automatically uses loading hook. that's difference between // option , subscriptions option above. waiton: function () { return meteor.subscribe('post', this.params._id); }
Comments
Post a Comment