How can I subscribe 2 subscriptions on the same collection (createContainer)

Lets says we are publishing two employees list’s, how can do we get two props for both lists? The problem is on the line with **??.

/// Example of the a server publication code ///

Meteor.publish('employees ', function () {
     return Employees.find({ type: 'current' } );
  });
 
Meteor.publish('oldemployees ', function () {
     return Employees.find({ type: 'past' } );
  });

// Example of the a clients code ///


export default createContainer( () => {
 
    Meteor.subscribe('employees ');
    Meteor.subscribe('oldemployees');
 
    return {
 
        employees: Employees.find({}).fetch(),
        **??
        oldemployees : Employees.find({}).fetch(),
        **??
 }
}, EmployeeList);

Can it be done ?

Thank’s

You just need to reproduce the same filter in the client-side query! See here: https://guide.meteor.com/data-loading.html#fetching

1 Like

Great, Thank you

Then I would just have a client code like this

// Example of the a clients code ///

   Meteor.subscribe('employees ');
  
    return {
 
        employees: Employees.find({ type: 'current' }).fetch(),
        oldemployees : Employees.find({ type: 'past' }).fetch(),
       
 }
}, EmployeeList);

I guess it can be done with just one publication them

1 Like

Yep! I think you’ve got the right idea.