Skip to content

Support distinct queries through query derivation [DATAMONGO-1985] #2856

Open
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions