Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Limit service return by date

Lets try to use return with some predefined values:
precode
{"_createdAt":{"$gte":{"$date":"2013-06-08T17:55:54.129Z"},"$lte":{"$date":"2013-07-10T17:55:54.129Z"}}}
/code/pre

if it works then please debug app and check that you use correct values in variables.

Tommy B
Posts: 0
Joined: Sat Sep 15, 2012 3:39 am

Limit service return by date

Your example worked. What i am figuring out is that the select list will not let me use a colon when storing a value in the component. Start Date and End Date are select list populated from a list service that is pulled from the appery db.

Tommy B
Posts: 0
Joined: Sat Sep 15, 2012 3:39 am

Limit service return by date

So my issue is that when i select the _createdAt date and display it in an alert it is not showing in iso format. How do i do that in Appery?

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Limit service return by date

Set "Date Format"= "yy-mm-dd" on "Datepicker" element.
than get date value from "Datepicker" :
pre
code
var s = $('div[dsid="startDate"] input').val();
var s1=s+'T00:00:00.00Z';
/code
/pre

Tommy B
Posts: 0
Joined: Sat Sep 15, 2012 3:39 am

Limit service return by date

Thank you VERY much. That did it. I have posted the complete code for other users.
codevar s = $('div[dsid="startDate"] input').val();
var e = $('div[dsid="endDate"] input').val();
var s1= s+'T00:00:00.00Z';
var e1= e+'T00:00:00.00Z';
return '{"_createdAt":{"$gte":{"$date":"' + s1 + '"},"$lte":{"$date":"' + e1 + '"}}}'/code

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Limit service return by date

Tommy, thank you for sharing!

Kirit Vaghela
Posts: 0
Joined: Tue Aug 27, 2013 11:23 am

Limit service return by date

Hello
I want to fetch particular records from collection using where clause.
I have create a database service with following settings

Name : user_category_list_service

URL : {database_url}/collections/user_category

Method : POST

Data Type : JSON

Settings : mySettings

Security Context : NONE

Content Type : JSON

Use Appery.io Proxy : not checked.

Request Parameters

X-Appery-Database-Id : {database_id} include in header
X-Appery-Session-Token : accesstoken include in header
Content-Type : application/json

Now I want records for particular user_id. How i pass where { "user_id" : "simple_user_id" }

Thanks

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

Limit service return by date

Hello! Add request parameter "where" (or you can create query service instead of list with "where" parameter added.

Do you mean under "user_id" _id field in builder?

If you use Test tab inside editor then add request in "where" field, for example code{"id": "520c76f6e4b04c2d0a0419bb"}/code
If you use in mapping then add JS which returns this line http://docs.appery.io/documentation/u...
For example:
codereturn '{"id": "' + value + '"}';/code

Tommy B
Posts: 0
Joined: Sat Sep 15, 2012 3:39 am

Limit service return by date

So I have now decided that I need to also filter on two collumns in the Database not one. I am using the following code that I have described above. Now I want to also limit the records to the user ID that is stored in local storage. The variable for the UserID is uid. codevar uid = Appery('unique').val();/code

How would I add two items in the where statement? I have tried many versions of this code but it doesnt work. codereturn '{"_createdAt":{"$gte":{"$date":"' + s1 + '"},"$lte":{"$date":"' + e1 + '"}},{"userID":"' + uid + '"}}'; /code

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Limit service return by date

Hi Tommy,

Lets try this:

prereturn '{$and: [{"_createdAt": $and: [{"$gte": {"$date": "' + s1 + '"}},{"$lte": {"$date": "' + e1 + '"}} ]}, {"userID":"' + uid + '"} ]}';/pre

Return to “Issues”