-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DATAMONGO-2153 - Aggregation support for repositories. #743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95a991d
to
cfd1d8c
Compare
The repository layer offers means interact with the aggregation framework via annotated repository finder methods. Similar to the JSON based queries a pipeline can be defined via the Aggregation annotation. The definition may contain simple placeholders like `?0` as well as SpEL expression markers `?#{ ... }`. public interface PersonRepository extends CrudReppsitory<Person, String> { @Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $?0 } } }") List<PersonAggregate> groupByLastnameAnd(String property); @Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $firstname } } }") List<PersonAggregate> groupByLastnameAndFirstnames(Sort sort); @Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $?0 } } }") List<PersonAggregate> groupByLastnameAnd(String property, Pageable page); @Aggregation("{ $group : { _id : null, total : { $sum : $age } } }") SumValue sumAgeUsingValueWrapper(); @Aggregation("{ $group : { _id : null, total : { $sum : $age } } }") Long sumAge(); @Aggregation("{ $group : { _id : null, total : { $sum : $age } } }") AggregationResults<SumValue> sumAgeRaw(); @Aggregation("{ '$project': { '_id' : '$lastname' } }") List<String> findAllLastnames(); } public interface ReactivePersonRepository extends ReactiveCrudReppsitory<Person, String> { @Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $?0 } } }") Flux<PersonAggregate> groupByLastnameAnd(String property); @Aggregation("{ $group : { _id : null, total : { $sum : $age } } }") Mono<Long> sumAge(); @Aggregation("{ '$project': { '_id' : '$lastname' } }") Flux<String> findAllLastnames(); }
cfd1d8c
to
133d159
Compare
Use MongoQueryMethod.getDomainClass() instead of getRepositoryDomainType(). Simplify annotation presence indicator methods hasAnnotatedSort() and hasAnnotatedCollation(). Refactor getAnnotatedAggregation() to non-nullable method throwing IllegalStateException to be consistent with other getXxx() methods. Simplify aggregation execution and consider collection/single element declaration for reactive execution. Tweak docs.
mp911de
pushed a commit
that referenced
this pull request
May 17, 2019
The repository layer offers means interact with the aggregation framework via annotated repository finder methods. Similar to the JSON based queries a pipeline can be defined via the Aggregation annotation. The definition may contain simple placeholders like `?0` as well as SpEL expression markers `?#{ ... }`. public interface PersonRepository extends CrudReppsitory<Person, String> { @Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $?0 } } }") List<PersonAggregate> groupByLastnameAnd(String property); @Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $firstname } } }") List<PersonAggregate> groupByLastnameAndFirstnames(Sort sort); @Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $?0 } } }") List<PersonAggregate> groupByLastnameAnd(String property, Pageable page); @Aggregation("{ $group : { _id : null, total : { $sum : $age } } }") SumValue sumAgeUsingValueWrapper(); @Aggregation("{ $group : { _id : null, total : { $sum : $age } } }") Long sumAge(); @Aggregation("{ $group : { _id : null, total : { $sum : $age } } }") AggregationResults<SumValue> sumAgeRaw(); @Aggregation("{ '$project': { '_id' : '$lastname' } }") List<String> findAllLastnames(); } public interface ReactivePersonRepository extends ReactiveCrudReppsitory<Person, String> { @Aggregation("{ $group: { _id : $lastname, names : { $addToSet : $?0 } } }") Flux<PersonAggregate> groupByLastnameAnd(String property); @Aggregation("{ $group : { _id : null, total : { $sum : $age } } }") Mono<Long> sumAge(); @Aggregation("{ '$project': { '_id' : '$lastname' } }") Flux<String> findAllLastnames(); } Original pull request: #743.
mp911de
added a commit
that referenced
this pull request
May 17, 2019
Use MongoQueryMethod.getDomainClass() instead of getRepositoryDomainType(). Simplify annotation presence indicator methods hasAnnotatedSort() and hasAnnotatedCollation(). Refactor getAnnotatedAggregation() to non-nullable method throwing IllegalStateException to be consistent with other getXxx() methods. Simplify aggregation execution and consider collection/single element declaration for reactive execution. Tweak docs. Original pull request: #743.
mp911de
added a commit
that referenced
this pull request
May 17, 2019
…ions. We now apply propagate the cursor size to aggregation options. We introduced AggregationOptions.comment to propagate the meta comment to aggregation execution. Original pull request: #743.
That's merged and polished now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The repository layer offers means interact with the aggregation framework via annotated repository finder methods. Similar to the JSON based queries a pipeline can be defined via the
@Aggregation
annotation. The definition may contain simple placeholders like?0
as well as SpEL expression markers?#{ ... }
.Sync
Reactive