O'Reilly logo

Meteor Design Patterns by Marcelo Reyna

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Aggregation publishers

Sometimes our database has a considerable amount of information that we want to synthesize. Some developers choose to publish all the information to the client and have the client synthesize it. This, as we have learned so far, can have a negative impact on performance. Other developers might use Meteor.method to return the synthesized data. This is definitely better for the client, but it will take a toll on our server if the computation is large.

The best way to handle a problem like this is to use MongoDB's aggregation framework to take the hard work of the calculation to our database, and then we can pair the results with the Meteor.publish special functions: @added, @changed, and @removed.

The aggregation framework

MongoDB's ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required