Skip to content

[Feature Request] Non Distinct Query / Distinct Options #5019

Closed

Description

@dplewis

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Finding non unique values

Describe the solution you'd like
A clear and concise description of what you want to happen.

Looking for fields with duplicates.
Maybe add a parameter for number of duplicates like 1, 2, or 3, $gt / $eq

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Currently using the following.

It groups all field values to be unique but keeps count of how many objects had that value.
If more than one object had that value its not unique.

db.collection.aggregate([
    { "$group": {
        "_id": "$field",
        "count": { "$sum": 1 }
    }},
    { "$match": {
        "count": { "$gt": 1 }
    }}
])

Additional context
Add any other context or screenshots about the feature request here.

Activity

  1. flovilmart commented on Aug 30, 2018

    @flovilmart
    Contributor

    Closing as a reasonable workaround is available. Adding a new API just for that seems overkill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions