Chapter 6. Aggregation

 

This chapter covers

  • Aggregation on the e-commerce data model
  • Aggregation framework details
  • Performance and limitations
  • Other aggregation capabilities

In the previous chapter, you saw how to use MongoDB’s JSON-like query language to perform common query operations, such as lookup by ID, lookup by name, and sorting. In this chapter, we’ll extend that topic to include more complex queries using the MongoDB aggregation framework. The aggregation framework is MongoDB’s advanced query language, and it allows you to transform and combine data from multiple documents to generate new information not available in any single document. For example, you might use the aggregation framework to determine sales by month, sales by product, or order totals by user. For those familiar with relational databases, you can think of the aggregation framework as MongoDB’s equivalent to the SQL GROUP BY clause. Although you could have calculated this information previously using MongoDB’s map reduce capabilities or within program code, the aggregation framework makes this task much easier as well as more efficient by allowing you to define a series of document operations and then send them as an array to MongoDB in a single call.

6.1. Aggregation framework overview

 

6.2. E-commerce aggregation example

 
 
 

6.3. Aggregation pipeline operators

 

6.4. Reshaping documents

 
 

6.5. Understanding aggregation pipeline performance

 
 
 

6.6. Other aggregation capabilities

 
 
 

6.7. Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage