Skip to content
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

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

Closed
dplewis opened this issue Aug 30, 2018 · 1 comment
Closed

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

dplewis opened this issue Aug 30, 2018 · 1 comment

Comments

@dplewis
Copy link
Member

dplewis commented Aug 30, 2018

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.

@flovilmart
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants