How to get all “Columns” from Parse platform “Table” using distinct, like GROUP BY on SQL

I’m using Parse with Postgres, and I need to retrieve some lines from a table.

I need to group by one column, just like the GROUP BY in SQL, but when I use the distinct or aggregate on my queries, both just return the column that I’m using as parameter, not all columns.


My table

Product | Category | Price
Apple   | Fruit    |     5
Orange  | Fruit    |     3
Rice    | Cereal   |     8
Grape   | Fruit    |     6

Then, I run the query:


Which results in:

["Fruit", "Cereal"]

But I want something like:

  {Product: Apple, Category: Fruit, Price:5},
  {Product: Rice, Category: Cereal, Price:8}

As I said, just like the GROUP BY via SQL.

It’s that possible?

Currently I’m using one query with the .distinct() and the results of that query as parameter in a .containedIn() , but I think that it must be a better way of doing this…
I tried to ask this question on stackoverflow, but nothing that they answered worked


Any update ?

Same problem, group and aggregate function (sum) work fine but just return the column that I’m using as parameter, not all columns :

       var pipeline = [
            group: { objectId: '$category', total: { $sum: '$price' } }


Which results in:

[{total: 10, objectId: "2H6t19LCbD"}]

But I want something like:

   objectId: "idGroupKey",
   total :10, 
   values:{[{Product: Apple, Category: Fruit, Price:5},{Product: Banana, Category: Fruit, Price:5},]}


parse-server : 3.9.0
db: postgre

Hello @tomadj, apparently it’s a limitation of postgre itself, it only returns the column used as groub by.
In this question they faced the same problem using postgre alone.

Ok :confused:

Thank you @dkribeiro !