Methods or Publish functions to read large datasets in mongo

What is the most efficient way to read data from sever: methods or publish functions?

I have collections linked to other collections so I need to write several queries to different collections to get the proper data that I need.

What’s the best way to get this data and what is best for reactive data and non reactive data methods or publish functions?

Thanks for your help

That depends on what you mean by efficient.

  • Methods are used to get a snapshot from your database. As far as the client is concerned, it’s static and won’t mutate if the document(s) fetched are changed on the database.
  • Pub/sub is used to get live updates from your database. As documents are added, changed or removed, your local data follows those changes.

Both approaches have their uses.

Thank you so much @robfallows for your reply.

Indeed I need reactivity. The dataset I need for the client have to be generated from several related/linked collections.

Using methods to get dataset from multiples collection is easy and I was trying to call them using simple:reactive-methods from a reactive context like helpers.

However, I think that pub/subs are specifically designed for this purpose. My question is how can I return a dataset from publish function, which was generated from multiples collections (several queries and specific logic) but the result is not precisely a collection (not a cursor) ?

Thank you again.

Check this part of the Meteor Guide.