我很高兴地看到Meteor 0.6.6中minimongo最近增加了与地理空间索引相关的$near支持。然而,$near的排序行为(应按距离顺序排序)似乎不具有反应性。也就是说,当一个文档被添加到集合中时,客户端会加载它,但始终在结果列表的末尾,即使它比其他文档更接近$near坐标。当我刷新页面时,顺序会得到纠正。
例如:
服务器:
有没有一种方法可以让它反应性地排序?
例如:
服务器:
Meteor.publish('events', function(currentLocation) {
return Events.find({loc: {$near:{$geometry:{ type:"Point", coordinates:currentLocation}}, $maxDistance: 2000}});
});
客户:
Template.eventsList.helpers({
events: function() {
return Events.find({loc: {$near:{$geometry:{ type:"Point", coordinates:[-122.3943391, 37.7935434]}},
$maxDistance: 2000}});
}
});
有没有一种方法可以让它反应性地排序?