Logan Wells
Posts: 0
Joined: Sat Oct 11, 2014 12:37 am

What is wrong with how I have combined two where clauses?

Hi,
I am having problems combining two where clauses:

I am trying to combine these clauses:
1.
var useridexpensevar = localStorage.getItem("useridexpense");
var whereObject = {"userprofid": {"$inQuery": {_id: useridexpensevar } //}};
return JSON.stringify(whereObject);

2.
var staridvar = localStorage.getItem("starid");
var whereObject = {"starid": {"$inQuery": {_id: staridvar } }};
return JSON.stringify(whereObject);

And this is what I have made:
var useridexpensevar = localStorage.getItem('useridexpense'), star = localStorage.getItem('starid');
var whereObject = {"userprofid": {"$inQuery": {id: useridexpensevar } } + {"starid": {"$inQuery": {id: star } } }};
return JSON.stringify(whereObject);

What is wrong with it? There are no JS issues int he console or any red flags when I put the code in.

Thanks

asid
Posts: 0
Joined: Sun Aug 09, 2015 8:01 pm

What is wrong with how I have combined two where clauses?

This is an example how I did it, not sure if this helps, I separated with a comma.

var whereClause = { "region": localStorage.getItem("myRegion"),
"menuItem": localStorage.getItem("mySubMenuItem")};
return JSON.stringify(whereClause);

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

What is wrong with how I have combined two where clauses?

Hello,

Please look at our documentation for queries like that: https://devcenter.appery.io/documenta...

Logan Wells
Posts: 0
Joined: Sat Oct 11, 2014 12:37 am

What is wrong with how I have combined two where clauses?

Aren't I doing the same thing with the $and but with a '+' sign, if I use the $and it comes up with errors.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

What is wrong with how I have combined two where clauses?

Hi Logan - Could you please show us your full where query string that you are using?

Logan Wells
Posts: 0
Joined: Sat Oct 11, 2014 12:37 am

What is wrong with how I have combined two where clauses?

The one labeled 'And this is what I have made: ' is the full string we are using.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

What is wrong with how I have combined two where clauses?

Sorry, I don't see anything - could you please repeat.

Logan Wells
Posts: 0
Joined: Sat Oct 11, 2014 12:37 am

What is wrong with how I have combined two where clauses?

Alright, my bad:
var useridexpensevar = localStorage.getItem('useridexpense'), star = localStorage.getItem('starid');
var whereObject = {"userprofid": {"$inQuery": {id: useridexpensevar } } + {"starid": {"$inQuery": {id: star } } }};
return JSON.stringify(whereObject);

Thanks

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

What is wrong with how I have combined two where clauses?

Logan, please use:

prereturn '{"$and":[{"userprofid": {"$inQuery": {"id": "'+useridexpensevar+'" } }}, {"starid": {"$inQuery": {"id": "'+star+'"}}}]}';/pre
instead of:

prevar whereObject = {"userprofid": {"$inQuery": {id: useridexpensevar } } + {"starid": {"$inQuery": {id: star } } }};
return JSON.stringify(whereObject); /pre

Logan Wells
Posts: 0
Joined: Sat Oct 11, 2014 12:37 am

What is wrong with how I have combined two where clauses?

Thanks so much! This was perfect

Return to “Issues”