Erwin Will
Posts: 0
Joined: Sat May 31, 2014 4:50 am

Multiple conditions for a Where clauses

I am trying to pass two local variables to one where clause. As seen in the documentation here http://devcenter.appery.io/documentat...

This is the code I am using. I have placed it in the Where clause.

var RestaurantNameObject = localStorage.getItem(RestaurantName);
var RestaurantHeaderObject = localStorage.getItem(RestaurantHeader);
var RestaurantNameJSON = JSON.stringify(RestaurantNameObject);
var RestaurantHeaderJSON = JSON.stringify(RestaurantHeaderObject);
return {"$and":[{"RestaurantName": RestaurantNameJSON},{"HeadingName": RestaurantHeaderJSON}]};

When I test the app I get an error with this description -- RestaurantName is not defined

I have RestaurantName and Header save in local variables from previous pages.

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

Multiple conditions for a Where clauses

Hello Erwin,

You should get data from localStorage this way:

codevar RestaurantNameObject = localStorage.getItem("RestaurantName"); /code
Thou you need to use ""
You get string from localStorage, not an object, so you don't have to use JSON.stringify()

Erwin Will
Posts: 0
Joined: Sat May 31, 2014 4:50 am

Multiple conditions for a Where clauses

I updated my code to
code
var RestaurantName = localStorage.getItem("RestaurantName");
var RestaurantHeader = localStorage.getItem("RestaurantHeader");
return {"$and":[{"RestaurantName": "RestaurantName"},{"HeadingName": "RestaurantHeader"}]};
/code

but when it I run it I get this error

GET https://api.appery.io/rest/1/db/colle... 400 (Bad Request)

You can see the application here http://appery.io/app/mobile-frame?src...

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

Multiple conditions for a Where clauses

Hello,

Please try use below code:
pre
var RestaurantName = localStorage.getItem("RestaurantName");
var RestaurantHeader = localStorage.getItem("RestaurantHeader");
return {"$and":[{"RestaurantName": "'+RestaurantName+'"},{"HeadingName": "'+RestaurantHeader+'"}]};
/pre

Return to “Issues”