0

I have two different templates in one route. Both return a number of items from a uniform collection however, when I do

Template.stepOneSelect.onCreated(function() {
  var instance = this;
  instance.autorun(function() {
    var subsciption = instance.subscribe('stepOne');
  });
  instance.occupations = function() {
    return Occupations.find();
  }
});

it returns Occupations from the whole route. There isn't a way for me to query the ones I need in one template because I query them on the server with other Collection that I am not subscribed to in that template.

So I need

Template.stepOneSelect.helpers({
    stepOneTitles: function () {
        return Template.instance().occupations();
    }
});

to only return the Occupations from that template and I am getting all the occupations from the route

// MORE INFO

I have two collections, CareerPaths and Occupations. CareerPaths has fields like occupationOneId which is an _id of the Occupation. It would be easy if I had a field in each Occupation that states which step of the CareerPath it is but one Occupation can be in different steps of a CareerPath. So I need to be returning Occupations based on CareerPaths. The route has two sections, one with a list of CareerPaths with a limit (only 10 at a time) and the other section should have ALL the Occupations from the first step of a career path, etc. I haven't found anything in publishComposite to only return the Children of a publication.

416serg
  • 348
  • 2
  • 17
  • this question has been asked before. I'll try to provide a link when I find the time to dig it up, but have a look yourself if you want a quick answer. – Christian Fritz Sep 16 '15 at 00:25
  • @ChristianFritz thanks Christian I tried to find the answer which I'm sure exists but I didn't have any luck :( would greatly appreciate the link – 416serg Sep 16 '15 at 00:41
  • 1
    http://stackoverflow.com/questions/12632452/publishing-subscribing-multiple-subsets-of-the-same-server-collection – Christian Fritz Sep 16 '15 at 01:31
  • @ChristianFritz I updated the question because I couldn't find an answer to it in the links provided :( – 416serg Sep 16 '15 at 15:56
  • I wouldn't think that what is being asked is possible without a helper that executes a query that can filter the same as the publish function was doing because any queries you run on a collection is running on the Client's minimongo instance which has everything provided by the server from publishers. Can your template helpers filter with the same conditions as your publish function? If not, I probably don't understand what you're trying to accomplish. – Lucas Blancas Sep 16 '15 at 19:48
  • @LucasBlancas thats the problem. they can't filter the same way as the publish function since the publish (server) has access to all of my CareerPaths and the Client only has access to the first 10. So my only option I guess is to publish all career paths to the client as well and only display the limit and have the other ones to be able to filter the right occupations, which seems like it would slow down performance in a case where I will have lots of CareerPaths, anyways thanks for your feedback! – 416serg Sep 17 '15 at 02:41

1 Answers1

0

If I am getting this right, you are trying to display only the data published by a particular subscription. The easy way to do this would be to move the query used in the publication into client/server code, then call the query from both the publication and the client-side query.

Gaelan
  • 1,149
  • 11
  • 25