Thomas Anderson7286790
Posts: 0
Joined: Sat Dec 20, 2014 3:46 pm

Multiple where clauses in a query

I finally got my where query working with a local storage item with the following javascript in the where JS tab on the input mapping on my service request:

//Get username in JSON format for where clause

var username = localStorage.getItem("username");
var whereObject = {"to_username": username};
return JSON.stringify(whereObject);

Now I would like to learn how to do an where $and query but can't seem to make it work.

I need where {"to_username": username}; AND {"activity":"active"}

I tried this code but it does not work:

//Get username in JSON format for where clause

var username = localStorage.getItem("username");
var whereObject = {"$and": [{"username": username},{"activity": "active"}]};
return JSON.stringify(whereObject);

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Multiple where clauses in a query

Hi Thomas,

You can combine your query conditions with $and clause like showed in code below:

pre

var username = localStorage.getItem("username");

var whereObject = {
$and: [
{"to_username": username},
{"activity": "active"}
]
};

return JSON.stringify(whereObject);

/pre

More info here: http://devcenter.appery.io/documentat...

Regards.

Thomas Anderson7286790
Posts: 0
Joined: Sat Dec 20, 2014 3:46 pm

Multiple where clauses in a query

Thanks. Got it working!

Return to “Issues”