minomongo 和发布者之间的流星反应问题

Meteor reactive issue between minomongo and publisher

我正在处理文档列表中的排序选项。同一排序查询同时具有发布者和客户端。如果两个或多个文档具有相同的排序值。当我更新很多时,我可以看到杂耍。下面的代码会解释的很清楚。

Meteor.publish('Products', function(options) {
    return Products.find({},sort:{price:-1})
});

Template.name.onCreated(function() {
    Template.instance().subscribe('Products');
});

Template.name.helpers({
    products: function(){
        return Products.find({},sort:{price:-1})
    }
});

Template.name.events({
    'click #productid': fucntion(){
        //update product document (not the price field).
    }
});

部分商品价格相同。我点击了价格相同的顶级产品。通过单击 event.The 更新文档后,单击的产品到达同一价格文档的末尾。如何解决这个问题?

希望我理解正确。要解决关系,您可以使用 _id 作为第二个排序参数。例如: { sort: {price: -1, _id: 1} }

此外,在您的出版物中使用 sort 不会改变此特定示例中的任何内容。如果需要,您可以将其删除。如果您在查询中使用 limit,出版物中的 sort 将会有所不同。