Adrian Stoch
Posts: 0
Joined: Thu Jul 31, 2014 3:09 pm

Distinct query sorted by Create Date for logged on user

The use case is as follows:

  • User can enter 1 or many comments on a post

  • User then wants to see a list of the posts they have commented on (the list must be distinct based on post ID to only show each post once)

  • The list is sorted to show most recent comments he has made first

    I am therefore attempting a query that:

  • Returns distinct values of the post ID

  • Where user = logged on user

  • In descending created date order

    When the query is a POST it ignores the where and sort parameters:
    Image
    Image

    When the query is a GET I receive the below error:
    Image
    Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Distinct query sorted by Create Date for logged on user

Hello Adrian,

When you use the GET method you should add header parameter Content-Type with a value of application/json.
For more information, please see the documentation http://devcenter.appery.io/documentat...

Adrian Stoch
Posts: 0
Joined: Thu Jul 31, 2014 3:09 pm

Distinct query sorted by Create Date for logged on user

Thanks Evgene, I missed the Content-Type setting in the Curl command.

That has fixed the where condition, but the sort is still not working. As you can see in the 3 screenshots below, the order remains the same irrespective of the sort parameter. I believe it is defaulting to ascending _createdAt. I need the order in descending _createdAt so the user sees latest comments first.

Image
Image
Image

obullei
Posts: 0
Joined: Thu Jun 05, 2014 12:17 am

Distinct query sorted by Create Date for logged on user

Hello!

Please note that when you get the distinct values ​​, the sort parameter is ignored
Please take a look here: http://stackoverflow.com/a/18478924
So, you can only get the desired column http://devcenter.appery.io/documentat... (sorting will work with query)
and select from all obtained values ​​using the unique JS (which may be implemented in the server code, or by means of generic services)

Adrian Stoch
Posts: 0
Joined: Thu Jul 31, 2014 3:09 pm

Distinct query sorted by Create Date for logged on user

Thank Arina, but I looked through the documentation of the Projection and can not see where the unique JS is described. Can you please point me in the direction of where this is explained how to implement.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Distinct query sorted by Create Date for logged on user

Hi Adrian,

There is no code example for JS(server code). So you should implement it yourself.
Here is documentation:
1 Tutorial: http://devcenter.appery.io/tutorials/...
2 Server code docs: http://devcenter.appery.io/documentat...

Regards.

Return to “Issues”