Reputation: 2296
I have a collection that I have to publish as a whole as well in part. The challenge now is that once I publish as a whole it overrides the one that is suppose to return only 5 at a time. The publishing with a set limit is to achieve pagination while publishing all goes into a dropdown box. How do I publish a collection so that none will override another?
This is publishing in part. Set with a limit of 5.
Meteor.publish('userSchools', function (skipCount) {
check(skipCount, Number);
user = Meteor.users.findOne({_id:this.userId})
if(user) {
if(user.emails[0].verified) {
return SchoolDb.find({userId: Meteor.userId()}, {limit: 5, skip: skipCount});
} else {
throw new Meteor.Error('Not authorized');
return false;
}
}
});
Published as a whole
Meteor.publish('allvalues', function () {
user = Meteor.users.findOne({_id:this.userId})
if(user) {
if(user.emails[0].verified) {
return SchoolDb.find({userId: Meteor.userId()});
} else {
throw new Meteor.Error('Not authorized');
return false;
}
}
});
Upvotes: 0
Views: 164
Reputation: 6018
This how Meteor pub-sub behaves. What you can do is put limit
and skipcount
in Subscribed collection as well inside template where you subscribe in parts.
Upvotes: 0