Page 1 of 4

multi query

Posted: Sun Jun 15, 2014 11:06 am
by Michael4771079

Hi,
can I ask you what is the best way to approach this. I could use "where" request but I dont see a way to do this with miltiple "wheres"

Its a search in a property rental app.
Below are screenshot of db and ui

in the ui I have 4 selectmenus
1 choose area
2 choose No of bedrooms
3 choose price range. (between 500 and 750 for eg)
4 Profession

What I am trying to achieve is to end up with an array

(of results of queries for eg. all 2 bed properties in a certain town with rent price between 500-750 suitable for profrssionals)

and be able to map the resulting array to a grid in the ui

Image

Image

thx inadvance


multi query

Posted: Sun Jun 15, 2014 11:33 am
by Illya Stepanov

Hi Michael,

I'm afraid the multiple 'where' requests could be implemented with several services for each query.
But I will check it additionally with our developers, maybe there is a much better implementation of this case.


multi query

Posted: Sun Jun 15, 2014 11:36 am
by Michael4771079

Thanks alot lllya, i didnt want to spend lots of time if my logic was not correct


multi query

Posted: Mon Jun 16, 2014 8:55 am
by Evgene Karachevtsev

Hello Michael,

There is documents about multiple where clauses: http://devcenter.appery.io/documentat...


multi query

Posted: Mon Jun 16, 2014 9:13 am
by Michael4771079

Hi Evgene,
I had read that, however I am still a bit lost, lllya suggested there may be a better way?


multi query

Posted: Mon Jun 16, 2014 10:25 am
by Illya Stepanov

Hi Michael, the most efficient way is to use $or and $and operators with 'where' clause.

Please describe where exactly you're having troubles with how to use it? Or show us some examples that you've tried and the parts where you want to make them in efficient way?


multi query

Posted: Mon Jun 16, 2014 10:55 am
by Michael4771079

Hi lllya,
I haven't started as I am unsure of how to implement.

Im struggling to figure out how to map the values of 4 selectmenus to the "where" Paramater

or do I need the values saved to localstorage and use js in mapping to add the $or and $and?

i could do it long way by doing a where for each select and eventually get the results to map to the ui but that looks wrong and slow.

If u have an example that would help alot

thanks folks


multi query

Posted: Mon Jun 16, 2014 12:30 pm
by Michael4771079

Hi,
am I on thre right track with this code, for a multi where from selectmenus

where Mapping code
codevar locationSelect = Apperyio("locationSelect ").val();
var bedroomSelect = Apperyio("bedroomSelect ").val();
var priceSelect = Apperyio("priceSelect ").val();
var professionSelect = Apperyio("professionSelect ").val();
return '{"$and": [{"locationSelect": "'+locationSelect+'"},{"bedroomSelect": "'+bedroomSelect'"},{"priceSelect": "'+priceSelect'"},{"professionSelect": "'+professionSelect'"}]}';/code


multi query

Posted: Mon Jun 16, 2014 2:57 pm
by Michael4771079

I have tried the above code in where mapping, working on test tab,

error on console

Image


multi query

Posted: Mon Jun 16, 2014 3:06 pm
by Michael4771079

some screenshots, my code is wrong

Image Image Image Image