Is there a way to tell meteor a collection is static (will never change)? -
on meteor project users can post events , have choose (via autocomplete) in city take place. have full list of french cities , never updated.
i want use collection , publish-subscribes based on input of autocomplete because don't want client download full database (5mb). there way, performance, tell meteor collection "static"? or make no difference?
could suggest different approach?
when "want tell server collection static", aware of 2 potential optimizations:
- don't observe database using live query because data never change
- don't store results of query in merge box because doesn't need tracked , compared other data (saving memory , cpu)
(1) can rather constructing own publish cursor. however, if client observing same query, believe meteor (at least in future) optimize it's still 1 live query number of clients. (2), not aware of straightforward way because potentially mess data merging on multiple publications , subscriptions.
to avoid using live query, can manually add data publish function instead of returning cursor, causes .observe()
function called hook data subscription. here's simple example:
meteor.publish(function() { var sub = this; var args = {}; // you're find()ing foo.find(args).foreach(function(document) { sub.added("client_collection_name", document._id, document); }); sub.ready(); });
this cause data added client_collection_name
on client side, have same name collection referenced foo
, or different. aware can many other things publications (also, see link above.)
update: resolve issues (2), can potentially problematic depending on size of collection, it's necessary bypass meteor altogether. see https://stackoverflow.com/a/21835534/586086 1 way it. way return collection fetch()
ed method call, although doesn't have benefits of compression.
Comments
Post a Comment