Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

How to Request the Most Recent Record from the Database

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!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to Request the Most Recent Record from the Database

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

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

How to Request the Most Recent Record from the Database

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to Request the Most Recent Record from the Database

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

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

How to Request the Most Recent Record from the Database

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

Thank you!

Return to “Issues”