Meteor Subscribe doesn't update sort order of collection

前端 未结 2 1205
无人共我
无人共我 2020-11-30 06:33
// Snippet from Template
{{#each elements}} {{> post-element this}} {{/each}}
// Snippet from Client M
2条回答
  •  感情败类
    2020-11-30 07:18

    You didn't posted your template helper code.

    When you do return Posts.find() from the helper function, the query should also contain the sort arguments, like as below:

    Template.myTemplate.elements = function(){
       Meteor.subscribe('thePosts');
       return Posts.find({},  {sort:{createdAt:-1}, reactive:true});
    }
    

提交回复
热议问题