Parse.com is equivalent to the By group

I read on the parsing forums and my understanding is that since 2 years ago there was no SQL Group By equivalent.

I'm wondering if there were any events on this? I have thousands of records and I need to output all records in descending order of nominal value and then group them by name.

If this is not currently available, maybe someone can suggest something that I could work on.

Sincerely.

+2


source to share


2 answers


See https://parse.com/docs/android_guide#queries-basic , you can have a secondary sort key that is equivalent to "group by".

query.orderByDescending("rating");
query.addAscendingOrder("name");

      



can do the trick for you.

+3


source


You have two options:

  • Refactor your schema to accommodate the model
  • Run a job to aggregate your data into "snapshots"

For Option 1, this means creating "afterSave" handlers that update the counters and so on. with data changes (expensive writes, cheap reads), here's a sample in the documentation that preserves the number of comments for the Post object:

https://parse.com/docs/cloud_code_guide#functions-aftersave



You will need to run a one-time job to set the initial counts since you already have the data (see option 2).

For Option 2, you can read more about background jobs by reading here:

https://parse.com/docs/cloud_code_guide#jobs

Your job is allowed to run for 15 minutes (for example, if it processes insane amounts of data or does a lot of things in sequence).

+2


source







All Articles