検索可能な大規模なデータセットがあります。ページをレンダリングする前にデータセット全体を送信するのは許容できないほど遅いため、現在は検索を含む部分のみを送信しています。
if ( Meteor.isClient ) {
Meteor.subscribe('events', Session.get('searchQuery'));
}
if ( Meteor.isServer ) {
Meteor.publish('events', function(searchQuery) {
return Events.find(searchQuery);
}
}
1 月に 10,000 件のイベントがあり、2 月に 5,000 件のイベントがあるとします。
//forgive the psuedo code
Session.set('searchQuery', { startDate: "2015-01-01", endDate: "2015-02-28"});
//wait a bit...
Event.find().count() // => 15,000, as expected.
//now I want to look at just February events
Session.set('searchQuery', { startDate: "2015-02-01", endDate: "2015-02-28"});
Event.find().count() // => 5,000, I've lost the January events.
// now I want to look at *just* the January events
// (I previously fetched these but subsequently lost them)
Session.set('searchQuery', { startDate: "2015-01-01", endDate: "2015-01-31"});
Event.find().count() // => 10,000, it takes a while to get all 10,000 records again.
私が望むのは、これらのレコードを 1 回だけ公開する必要があり、結果のクライアント側コレクションが以前のすべての結果の結合であることです。
Session.set('searchQuery', { startDate: "2015-01-01", endDate: "2015-02-28"});
//wait a bit...
Event.find().count() // => 15,000, as expected.
//now I want to look at just February events
Session.set('searchQuery', { startDate: "2015-02-01", endDate: "2015-02-28"});
Event.find().count() // => 15,000, I've retained the January events.
Event.find({ startDate: "2015-02-01", endDate: "2015-02-28"}).count() // => 5,000
// now I want to look at *just* the January events
// (I previously fetched these but subsequently lost them)
Session.set('searchQuery', { startDate: "2015-01-01", endDate: "2015-02-31"});
Event.find().count() // => 15,000, still have all the records
Event.find({ startDate: "2015-01-01", endDate: "2015-01-31"}).count() // => 10,000, instantly without needing the records to be republished
pub/sub がすぐにこのように機能するとは思いませんが、この動作に近似できる方法はありますか?