spring-projects / spring-projects/spring-data-mongodb

Support distinct queries through query derivation [DATAMONGO-1985]

Open
#2,856 1 comment 1 reaction 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.