Spring Data MongoDB
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 inspring.data.mongodb.uri.@Documentclasses andMongoRepository<Review, String>give CRUD and derived queries.@Indexedand@CompoundIndexdeclare indexes; check that they really exist in production.- Complex summaries use
MongoTemplatewith anAggregation, or@Aggregationon a repository.
Draft outline details
Demonstration
@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.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.