Page 2 of 3

Limit service return by date

Posted: Sun Jul 21, 2013 3:11 pm
by Igor

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.


Limit service return by date

Posted: Tue Jul 23, 2013 9:49 pm
by Tommy B

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.


Limit service return by date

Posted: Tue Jul 23, 2013 11:31 pm
by Tommy B

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?


Limit service return by date

Posted: Wed Jul 24, 2013 3:34 am
by Igor

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


Limit service return by date

Posted: Thu Jul 25, 2013 12:09 am
by Tommy B

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


Limit service return by date

Posted: Thu Jul 25, 2013 12:30 am
by Alena Prykhodko

Tommy, thank you for sharing!


Limit service return by date

Posted: Fri Aug 30, 2013 8:49 am
by Kirit Vaghela

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


Limit service return by date

Posted: Fri Aug 30, 2013 10:58 am
by Maryna Brodina

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


Limit service return by date

Posted: Tue Sep 03, 2013 4:13 am
by Tommy B

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


Limit service return by date

Posted: Tue Sep 03, 2013 6:42 am
by Anton Artyukh5836028

Hi Tommy,

Lets try this:

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