Alan Sikora
Alan Sikora

Reputation: 557

How to subscribe to two different publications for the same collection?

I have this situation:

How's that possible on Meteor?

Thank you!

Upvotes: 0

Views: 113

Answers (2)

Alan Sikora
Alan Sikora

Reputation: 557

Actually I've found a good workaround for my issue. Subscribing to a count:

Meteor subscribe to a count

There is an example on Meteor's documentation:

http://docs.meteor.com/#meteor_publish

Maybe this will help someone in the future.

Upvotes: 2

Andrey
Andrey

Reputation: 107

Those requests will depend on the structure of your Lists and Emails collections.

If your Lists collection is base on _id and an array of Email _id. Then to show e-mail for a specific list:

Meteor.publish('emails_for_list', function(list){
  return Emails.find({
    _id: {$in: list.emails} 
  });
});

As for counting the total number of emails sent on a day.

  return Emails.find({submitted_date: today}).count();

Again it all depends on how you build you collections. Instead of having a Lists collection you can as easy put an list_number on each email object.

Upvotes: 0

Related Questions