Apart from using a mapreduce pipeline to write complex queries in MongoDB, it also provides an aggregate

Question:

Apart from using a map–reduce pipeline to write complex queries in MongoDB, it also provides an “aggregate” command through which you can define an aggregation pipeline consisting of several stages (filtering, limiting, grouping, and sorting), as we’ve discussed in the chapter. Would it be possible to write the following query:

SELECT genre, SUM(nrPages) FROM books GROUP BY genre ORDER BY genre

also as an “aggregate” command instead of using a map–reduce pipeline? For which types of queries would aggregation become harder in MongoDB?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: