Page 1 of 1

Multiple where clauses in a query

Posted: Mon Jan 05, 2015 3:25 am
by Thomas Anderson7286790

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);


Multiple where clauses in a query

Posted: Mon Jan 05, 2015 4:55 am
by Yurii Orishchuk

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.


Multiple where clauses in a query

Posted: Tue Jan 06, 2015 2:13 am
by Thomas Anderson7286790

Thanks. Got it working!