Cj Bernauer
Posts: 0
Joined: Wed Oct 22, 2014 5:47 pm

How to add multiple "where" parameters to query request

http://appery.io/app/view/d0daa76e-05...
This is a link to test the app. Login as Frank and use the password "test" to login.

Currently, when you tap "add hours" it will open a side panel allowing user to input their worked hours. After this, the hours in the current session will be listed on the main screen. This is done using the query service and using "where" parameter with the value: {"draft": "true"}</pre

What I want to do however is make sure only items being submitted by the current user are displayed. I already have the username locally stored as "localStorage".
How do I add something like {"user": localstorage} to the where parameter?

Cj Bernauer
Posts: 0
Joined: Wed Oct 22, 2014 5:47 pm

How to add multiple "where" parameters to query request

Thanks, so I'm seeing I'd use "$and" but how do I use the value of localstorage? I only see how to set it as a specific value like {"user":"localstorage"}..

Cj Bernauer
Posts: 0
Joined: Wed Oct 22, 2014 5:47 pm

How to add multiple "where" parameters to query request

Anyone wanna point me in the direction where I can find out how to do that?

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

How to add multiple "where" parameters to query request

Hello Cj,

We are working on it and will get back to you with the update.

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

How to add multiple "where" parameters to query request

Hi Cj,

Yes you need to use "$and" clause.

So please use following JS code for "where" request parameter:

pre

&#47;&#47;Where "userIdLSV" is LSV where you store current user id&#46;
var userId = localStorage&#46;getItem("userIdLSV");

&#47;&#47;Note: in this implementation "user" - is string type with value current id&#46;
&#47;&#47;If there user is "pointer" type to users collection you should use $inquery clause&#46;
var whereObject = {"$and": [ {"draft": "true"}, {"user": userId} ] };

return JSON&#46;stringify(whereObject);

/pre

Also if you still will have the problem please show us your DB collections screen shots.

And it's better to provide us information about login/password to access your app.

Regards.

Cj Bernauer
Posts: 0
Joined: Wed Oct 22, 2014 5:47 pm

How to add multiple "where" parameters to query request

Thank you!! Worked perfectly!

Return to “Issues”