An aggregation pipeline can replace and augment querying operations in the shell. A common pattern for development is as follows:
- To verify that we have the correct data structures and get quick results using a series of queries in the shell
- To prototype pipeline results using the aggregation framework
- To refine and refactor if/when needed, either by ETL processes to get data into a dedicated data warehouse, or by more extensive usage of the application layer to get the insights that we need
In the following table, we can see how SQL commands map to the aggregation framework operators:
SQL |
Aggregation framework |
WHERE/HAVING |
$match |
GROUP BY |
$group |
SELECT |
$project |
ORDER BY |
$sort |
LIMIT |
$limit |
sum()/count() |
$sum |
join |
$lookup |