I have mongo model Posts. And two templates with different criteria.
I would like to see: in one template - posts ordered by -1, in second - posts ordered by 1. Both - limited - by 5.
So, I made simple publish (In real life it’s a little more parameters).
Meteor.publish('posts',function() {
return Posts.find({},{limit:5,sort:{createdAt: 1}});
});
Meteor.publish('postsback',function() {
return Posts.find({},{limit:5,sort:{createdAt: -1}});
});
And template subscription like:
Template.postone.onCreated(function(){
this.subscribe('posts');
});
Template.posttwo.onCreated(function(){
this.subscribe('postsback');
});
Template.postone.helpers({
posts: function(){
return Posts.find();
}
});
Template.posttwo.helpers({
postsback: function(){
return Posts.find();
}
});
I hade - posts equals in order and have no limits. Where I had made mistake?