Change subscription base on other subscription

Consider the following simple case:

foos = new Meteor.Collection('foos');
bars = new Meteor.Collection('bars');
foobar = new Meteor.Collection('foobar');

foos schema:

{
  _id: id
}

bars schema:

{
  _id: id
  foo_id: foo_id
}

foobar schema:

{
  _id: id
  bar_id: bar_id
}

What I want is to publish foobar wrt to the given foo.

Meteor.publish(‘foobars’, function(foo_id) {
// code here
});

Anyone have an idea how to do this?

Use publish-composite. See the relevant article in the Meteor Guide: http://guide.meteor.com/data-loading.html#publishing-relations

1 Like