Page 1 of 1

how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 4:57 pm
by AC

Hi,

I have used the query service and successfully get the results shown in my app.

But all results are shown from oldest date to latest date. I want to put the latest result in the top of the list. How can I make it happen?

Please help.


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 6:48 pm
by Illya Stepanov

Hi AC -

Add sort parameter to the service and by default place "-createdAt" value(without "" of course).


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 7:07 pm
by AC

Image

where to change?


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 7:15 pm
by M&M

Add the sort parameter to the Request Parameter of the service.

Like this

Image

And to sort in descending order, specify the col name with “-” before it


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 8:54 pm
by AC

Hi MM, thx for the helping. After setting in the request section. Should I also map something new in the response section. I post a snapshot below, please help


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 8:55 pm
by AC

Image

after adding this and map it, I can get first three pictures from latest date to oldest date, but rest of picture still keep same sorting way...do i map something wrong ?


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 8:58 pm
by AC

the second step- put "-" in front of col name. Do u mean sort the col in the database? Or I need to make some setting in the response mapping?


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 9:06 pm
by M&M

Nope you don't have to do any additional mapping for sorting. Just need to add "sort" parameter and on the right side add the column name, in your case createdAt. In case you want to sort in descending order then use -createdAt


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 9:07 pm
by M&M

You just need to follow this picture
https://d2r1vs3d9006ap.cloudfront.net...


how can i change the query service results displaying sequence?

Posted: Mon Jan 26, 2015 9:47 pm
by AC

Made it happen! Thx a lot MM!