Page 1 of 1

How to Request the Most Recent Record from the Database

Posted: Tue Oct 22, 2013 6:40 am
by Christopher Herold

Hi!

I am trying to return the most recent record from my database by sorting with _updatedAt and putting a limit of 1. I am not sure I have the correct syntax.

I am placing the javascript below in the where clause of the database request. It does not seem to function.

Any thoughts on how to get this working?

codereturn '{ $and:[ {"owner":"'+value+'"}, {"sort":"-_updatedAt"}, {"limit":"1"} ] }'; /code

Thanks!


How to Request the Most Recent Record from the Database

Posted: Tue Oct 22, 2013 8:43 am
by Maryna Brodina

Hello! sort and limit shouldn't be in where parameter, they are separate parameters. Please take a look at the screenshot:
Image


How to Request the Most Recent Record from the Database

Posted: Wed Oct 23, 2013 4:46 am
by Christopher Herold

That's not what I see for my service listing. Check out the screen shot from the test section of my query_service set-up. Why is mine different from yours? I do not have a sort or a limit request box.

Image


How to Request the Most Recent Record from the Database

Posted: Wed Oct 23, 2013 6:01 am
by Maryna Brodina

Hello! You have to add these parameters on Request tab.


How to Request the Most Recent Record from the Database

Posted: Wed Oct 23, 2013 6:09 am
by Christopher Herold

I see now. It is necessary to enter the new parameters in the Request section of the service.

Thank you!