This module provides annotated support for MongoDB aggregate queries much like the @Query annotation provided by the Spring Data module.
The @Query annotation provided by Spring Data MongoDb allows queries to be executed with minimum code being written.
It is highly desirable to have a similar mechanism for MongoDB aggregate queries which allow us to execute sophisticated
queries with practically no code being written.
Not all aggregate pipeline steps are supported. As of 0.7.2 support is provided for
- Project
- Unwind
- Lookup
- Group
- Match
- Out
- Limit
- Bucket (Mongo 3.4+) - added in v0.7.2
- AddFields (Mongo 3.4+) - added in v0.7.2
- ReplaceRoot (Mongo 3.4+) - added in v0.7.2
Minimum Java version supported is 1.8
See the unit test classes and test repository definitions for examples of how to use the Aggregate query annotations.
The @Aggregate annotation is used identically to the way the Spring data @Query annotation is used. You can put the annotation on any interface method (with placeholders) to get Aggregate query support. The easiest way to do this is to test the pipeline on a MongoDB client (like RoboMongo or MongoChef) and then copy the pipeline steps into each annotation.
- Kollivakkam Raghavan (owner)
- Sukhdev Singh
- Cameron Javier