How do i use path data from FlowRouter to filter a collection?

I’ve let myself get a bit confused and turned around. I’ve got root/tags/tagname and i want to use tagname to filter my results but after i get the tag name from flow router i don’t know how and where i need to be passing that to filter my collection.

Do you want to filter the collection locally, or do you want the server to only publish that data to your client? It usually makes most sense to filter on the server, unless it isn’t a lot of data to begin with.

If that is what you want to do then you need to resubscribe to the collection - and pass arguments into the subscription call which tell the server what to filter by.

If you’re looking to filter the collection locally, then wherever you query the MongoDB you need to check the FlowRouter Params and then do the filtering.

yeah, on the server… does anyone have an example i could see where this is accomplished using flow router?

From the flow router docs:

FlowRouter.route('/blog/:postId', {
    subscriptions: function(params) {
        console.log("subscribe and register this subscription as 'myPost'");
        this.register('myPost', Meteor.subscribe('blogPost', params.postId));
    action: function(params) {
        console.log("Yeah! We are on the post:", params.postId);

You can see the subscription here is based on the postID parameter.
In your example, you just need to think which parameter you want to submit to the server when subscribing…

In this bit:

Meteor.subscribe('blogPost', params.postId));

You can have whatever you like in place of params.postId - you can submit an object even like this:

Meteor.subscribe('blogPost', { filter_on: params.whateverYouLike, limit: 100, etcetera: true }));

Have a quick read of the publish docs again if what you are really asking is how to handle the input argument into the publication. It isn’t hard but with all the moving parts it can get confusing.

thanks again for all the help i got it now