spring-projects / spring-projects/spring-data-mongodb
Support distinct queries through query derivation [DATAMONGO-1985]
Open
@mp911de is already working on this.
Since Dec 30, 2020.
type: enhancement
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Mark Paluch opened DATAMONGO-1985 and commented
It would be great to support distinct queries using closed projections and repository query methods. Given a closed projection selecting a single field (or string queries projecting a single field) we should be able to construct distinct queries.
public interface FooBarRepository extends ReactiveCrudRepository<FooBar, String> {
Flux<IdentifierOnly> findDistinctByFooAndBar(String foo, String bar);
}
The document / collection class:
@Document
public class FooBar {
private String identifier; // not unique
private String foo;
private String bar;
// extra fields
// getters and setters
}
The closed projection:
public interface IdentifierOnly {
getIdentifier();
}
Reference URL: https://stackoverflow.com/questions/50473631/spring-data-mongodb-reactive-distinct-not-working
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.