Day 21, no more auto publish with Meteor.com

Besides grocery shopping, I finally got rid of autopublish for one of my Meteor projects.

With Meteor, it is incredibly easy to get things up and running. By default, Meteor autopublish everything in your collection to clients. It works perfectly until your collection / database becomes too large to download for the client. I am at this moment now.

It was daunting at the beginning, but I manged to get it through. According to my very limited knowledge, it seemed to work like this:

Step 1, remove autopublish:


meteor remove autopublish

Step 2, at the server side, publish the collection

Meteor.publish('pics_filtered', function(filter){
return Pics.find({day:filter});
});
Step 3, at the client side, catch the collection.

Pics = new Meteor.Collection('pics');
Session.set('today_filter', 17);
Deps.autorun(function () {
Meteor.subscribe("pics_filtered", Session.get("today_filter"));
});

Step 4, there is no step 4. It seems like Deps.autorun() was responsible for catch and bind data to the collection at client side. Still not 100% sure though.

I have to vent. Look at the following specifications for JS….

– setMonth Sets the month (0-11) for a specified date according to local time.

– setDate Sets the day of the month (1-31) for a specified date according to local time.

Advertisements
Standard