Hello,
Update:
Hello,
For some reason instead of having a page with the set amount of limits my page keeps getting more and more elements shown (starts with 3, then more and more added, also can’t go back with prev).
Any idea why? Here’s the code I use:
Event handling
"click .nxtpage_over": function(event, template){
Session.set('skip', (Session.get('skip') || 0) + 3);
console.log("Going next page "+Session.get('skip')+" Limit is :"+Session.get('limit'));
Meteor.subscribe('overtime', {skip:Session.get('skip'), limit:Session.get('limit')});
},
"click .prepage_over": function(event, template){
Session.set('skip', (Session.get('skip') || 0) - 3);
console.log("Going prev page "+Session.get('skip')+" Limit is :"+Session.get('limit'));
Meteor.subscribe('overtime', {skip:Session.get('skip'), limit:Session.get('limit')});
// Meteor.subscribe('overtime', {limit:Session.get('limit') || 3}, {skip:Session.get('skip') || 0});
},
HTML/Template
<button class="prepage_over"> Previous Page </button>
<button class="nxtpage_over"> Next Page </button>
Server-sided publish
Meteor.publish('overtime', function(opt){
if (!Roles.userIsInRole(this.userId, 'admin')) {
return Overtime.find({userId: this.userId}, opt);
} else {
return Overtime.find({}, opt);
}
});
Client-sided initial subscribe (declared just in main.js, it’s not inside a function)
Session.set('limit', 3);
Meteor.subscribe('overtime', {limit:Session.get('limit')});
Old post:
So, I’ve decided to stress test my application. Created a loop and added 10,000 entries. After entries been finally added I found out that the lag on my machine (client-side) is real. The only way to quick solve it was to add a server-sided limit.
Meteor.publish('trips', function(){
return Trips.find({}, {limit:100});
});
Is there a better way of doing this? Pagination perhaps?