Skip to content
Ameen Abozaid
Planned lessonMID-042-L07

Demo: building the reviews service on MongoDB

  • Lesson 7 of 7
  • Mid-level
On This Lesson 3 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

build the reviews service with a ratings summary. Prepares MID-042-LAB1.

Draft outline details

Step by step

  1. Create the Review document and repository; add POST /products/{id}/reviews and GET for the latest 20.
  2. Add the compound index { productId: 1, createdAt: -1 } and prove IXSCAN with explain.
  3. Add GET /products/{id}/rating-summary using an aggregation ($match, $group average and count).
  4. Run it against 100 000 seeded reviews; compare timings with and without the index.
  5. Planned mistake: embed the review list inside a ProductReviews document; at a few thousand reviews updates slow down. Fix: one document per review and a separate summary.
  6. Use Testcontainers with a MongoDB image for the integration test (verify image tag).

Check your understanding

Where is the average computed?

Show answer

In the database, by the aggregation pipeline.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.