Skip to content
Ameen Abozaid
Planned lessonMID-042-L06

Spring Data MongoDB

  • Lesson 6 of 7
  • Mid-level
On This Lesson 4 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

use MongoDB from Spring.

Planned topics

  • spring-boot-starter-data-mongodb; connection in spring.data.mongodb.uri.
  • @Document classes and MongoRepository<Review, String> give CRUD and derived queries.
  • @Indexed and @CompoundIndex declare indexes; check that they really exist in production.
  • Complex summaries use MongoTemplate with an Aggregation, or @Aggregation on a repository.
Draft outline details

Demonstration

java
@Document("reviews")
record Review(@Id String id, long productId, int rating, String text, Instant createdAt) {}
interface ReviewRepo extends MongoRepository<Review, String> {
    List<Review> findTop20ByProductIdOrderByCreatedAtDesc(long productId);
}

Check your understanding

Where do you put a pipeline with $group?

Show answer

In MongoTemplate aggregation or @Aggregation.

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.

Continue to next lesson

Type to search levels, phases, modules and lessons.