Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Query Service with multiple "Where" parameters

Hi,

I have this service which has a where parameter, and it work perfectly if I only need one parameter. However I need 2 or more, so how can I add another where parameter?

For example in my case,
I want the app to show the shops that are located in the text value of "mobileCollapsblock_changiVillage" estate, and fall under the category of the text value of "mobileheader_confectionery".

The first pic show the mapping of the before send event.
The second pic show the coding inside the "JS".

Thanks!

Image

Image

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

Query Service with multiple "Where" parameters

Hi Rui -

You can't link value to the one parameter, use jQeury to search your components on the page with JS in this parameter instead.

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Query Service with multiple "Where" parameters

Hi,

Is there a more specific way?

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Query Service with multiple "Where" parameters

Hi,

I don't quite understand, is there a more specific way?
thanks.

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Query Service with multiple "Where" parameters

Have a look at this image

Image

In your case replace the Age and Name with your column names and as you need to do and i have used the greater than operator. You can remove that and do the same as what I did with the Name. But you may want to check out the case-sensitivity as well

a simple and query for Age =33 and Name equals "Susan" goes like this
{"$and": [{"Age": {"$gt": 25} },{"Name": "Susan"}]}

You will need to replace the hard coded values with values from the UI components

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Query Service with multiple "Where" parameters

Hi,

Thanks for your help, but I'm actually doing a list loop here with 2 parameters, etc "Where category = Confectionery And estate = "Ixora". I want the value of the shop name, operating hours, image and address for each row to be shown differently accordingly to the database.
Is it possible to do a query like what you did, and sup in the values for each loop? If so, how the codes should be like?
Thanks!

Image

Image

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Query Service with multiple "Where" parameters

You can do it by adding this parameters in your Service Request parameters

Image

You may not be wanting to hard code the values but to fetch it dynamically from the user input, in which case you will just need to map the values of the input boxes to the where clause / parameters

And ya the query assumes that the column names are "Category" and "Estate"

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Query Service with multiple "Where" parameters

Hi,

Sorry to bother you again, being a newbie here, so how exactly can I make the category and estate dynamic? what exactly should I put inside the query string value and the JS of the mapping?
Do I still map it the same way like this?
Thanks!

Image

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Query Service with multiple "Where" parameters

Nope, this mapping is wrong. You can add the "where" clause under the "Request" tab - in Service properties

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Query Service with multiple "Where" parameters

Yup, I added the where clause under the request tab just like you did. But I don't want the category and estate always to be Confectionery and Ixora. As I want to use this service with different category and estate else where in the app. Can it be done? Or did I misunderstanding something? Thanks.

Return to “Issues”