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

Find the distinct values for a specified column #2238

Closed
finnhlarsen opened this issue Jul 8, 2016 · 24 comments
Closed

Find the distinct values for a specified column #2238

finnhlarsen opened this issue Jul 8, 2016 · 24 comments
Labels
type:feature New feature or improvement of existing feature

Comments

@finnhlarsen
Copy link

Find the distinct values for a specified column across a single table and returns the result,

Based on this discussion:
https://www.parse.com/questions/retrieving-unique-values

@flovilmart
Copy link
Contributor

This is not implemented yet but you could work on a PR that implements it

@codebreach
Copy link
Contributor

I can take this up. Is there a API design for this?
looking at how REST queries work I would assume it to look something like:

curl -X GET \
  -H "X-Parse-Application-Id: REDACTED" \
  -H "X-Parse-REST-API-Key: REDACTED" \
  -G \
  --data-urlencode 'distinct=score' \
  https://api.parse.com/1/classes/GameScore

@flovilmart
Copy link
Contributor

We usually Mark custom operators with a $ i.e. $distinct

@ranhsd
Copy link
Contributor

ranhsd commented Sep 18, 2016

Any news regarding this enhancement ?

thanks.

@flovilmart
Copy link
Contributor

@ranhsd It's up for the taking :)

@ranhsd
Copy link
Contributor

ranhsd commented Sep 21, 2016

@flovilmart This change should be done in the DataBaseController.js right ?

@acinader
Copy link
Contributor

@ranhsd, I just poked around out of curiosity, I'd think that you'd need to add it first to RestQuery which will call find on the DataBaseController that will then use the MongoCollection.find (or postgress). Would at least need to touch a comment in LiveQuery/QueryTools.js

This is just my quick look around. Seems like following how skip and limit are done are good parallels since they are constraints on a find, like distinct is.

ymmv :)

@otmezger
Copy link

+1 for this feature

@oallouch
Copy link
Contributor

oallouch commented Oct 3, 2016

I know MongoDB well and what would be great for me is a way to use mongo directly, with the aggregation framework and all. I know it's a lot a ask.

@joshgare
Copy link

joshgare commented Nov 3, 2016

+1

@pewh
Copy link

pewh commented Mar 5, 2017

+1 Any news on this implementation?

@natanrolnik
Copy link
Contributor

@pewh no, but PRs are more than welcome 😉

@Cliffordwh
Copy link

Im sure there was a PR already for this! can anybody confirm?

@ridergeek
Copy link

+1 for this. @Cliffordwh - I did a quick search on open/closed PRs and couldn't find this. Hoping someone will pick this up and implement soon.

@shi1hh
Copy link

shi1hh commented May 28, 2017

china parse

Key Operation

  • groupby
  • groupcount
  • sum
  • average
  • max
  • min
  • having
curl -X GET 
    `-H "X-Bmob-Application-Id: Your Application ID" \
    -H "X-Bmob-REST-API-Key: Your REST API Key" \
    -G \
    --data-urlencode 'groupby=score' \
    https://api.bmob.cn/1/classes/GameScore

[
    {
        "score": 78
    },
    {
        "score": 89
    }
]


curl -X GET \
    -H "X-Bmob-Application-Id: Your Application ID" \
    -H "X-Bmob-REST-API-Key: Your REST API Key" \
    -G \
    --data-urlencode 'sum=score&groupby=createdAt&groupcount=true&order=-createdAt' \
    https://api.bmob.cn/1/classes/GameScore

[
    {
        "_sumScore": 2398,
        "_count": 10,
        "createdAt": "2014-02-05"
    },
    {
        "_sumScore": 100,
        "_count": 2,
        "createdAt": "2014-01-01"
    },
]

curl -X GET \
    -H "X-Bmob-Application-Id: Your Application ID" \
    -H "X-Bmob-REST-API-Key: Your REST API Key" \
    -G \
    --data-urlencode 'sum=score1,score2&groupby=createdAt,playerName&order=-_sumscore1' \
    https://api.bmob.cn/1/classes/GameScore

[
    {
        "_sumScore1": 399,
        "_sumScore2": 120,
        "playerName": "John"
        "createdAt": "2014-02-05"
    },
    {
        "_sumScore1": 299,
        "_sumScore2": 250,
        "playerName": "Bily"
        "createdAt": "2014-02-05"
    },
    {
        "_sumScore1": 99,
        "_sumScore2": 450,
        "playerName": "John"
        "createdAt": "2014-02-01"
    },
]

link http://docs.bmob.cn/data/Restful/b_developdoc/doc/index.html

@wy1024
Copy link

wy1024 commented Jun 26, 2017

After hours of looking, the only solution i found is to get all rows and do distinct by yourself.

To get all rows, beyond the limit of 1000, and the skip limit of 10000, this is a great solution.
http://cyber-duck.github.io/2016/03/18/how-to-retrieve-all-objects-on-parse-without-api-limitation/

@natanrolnik
Copy link
Contributor

@davimacedo We could have some query parameters to select distinct values, no? What do you think?

@davimacedo
Copy link
Member

I think the API suggested in the beginning of the thread would be good:
curl -X GET
-H "X-Parse-Application-Id: REDACTED"
-H "X-Parse-REST-API-Key: REDACTED"
-G
--data-urlencode 'distinct=score'
https://api.parse.com/1/classes/GameScore

We would have to handle this in ClassesRouter -> rest -> RestQuery -> DataBaseController -> Mongo and Postrgres adapters.

For mongo we can implement it using https://docs.mongodb.com/manual/reference/method/db.collection.distinct/.

For postgres using SELECT DISTINCT ... (https://www.postgresql.org/docs/9.0/static/sql-select.html)

I've just added it to my personal kanban. I can try to write something soon.

@drmark1989
Copy link

We really need this

@dplewis
Copy link
Member

dplewis commented Nov 12, 2017

Closes #2238 Via #4207

@dplewis dplewis closed this as completed Nov 12, 2017
@fmendoza
Copy link

Does the new aggregate queries support pointers?

@dplewis
Copy link
Member

dplewis commented Dec 22, 2017

I don’t think so. But it does support dot notation. Feel free to open a PR, we’ll review it. You could do distinct(PointerField.objectId) but that’s just a workaround

@fmendoza
Copy link

yeah I tried your suggestion before (pointer.objectId) before but no results

@dplewis
Copy link
Member

dplewis commented Dec 22, 2017

It’s up for the taking 😉

@mtrezza mtrezza added type:feature New feature or improvement of existing feature and removed type:improvement labels Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

No branches or pull requests