Page 1 of 1

How to add multiple "where" parameters to query request

Posted: Mon Dec 01, 2014 2:00 pm
by Cj Bernauer

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?


How to add multiple "where" parameters to query request

Posted: Mon Dec 01, 2014 2:28 pm
by Maryna Brodina

Hello!

Let us know if this helps http://devcenter.appery.io/documentat...


How to add multiple "where" parameters to query request

Posted: Mon Dec 01, 2014 2:41 pm
by Cj Bernauer

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"}..


How to add multiple "where" parameters to query request

Posted: Mon Dec 01, 2014 8:41 pm
by Cj Bernauer

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


How to add multiple "where" parameters to query request

Posted: Mon Dec 01, 2014 8:46 pm
by Evgene Karachevtsev

Hello Cj,

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


How to add multiple "where" parameters to query request

Posted: Mon Dec 01, 2014 11:46 pm
by Yurii Orishchuk

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.


How to add multiple "where" parameters to query request

Posted: Tue Dec 02, 2014 2:16 pm
by Cj Bernauer

Thank you!! Worked perfectly!