Page 2 of 5

How to use search to query multiple database columns

Posted: Mon Jan 12, 2015 2:22 am
by Ellen Schlechter

So I have a similar situation. I want to search on multiple columns in the database. This is what I tried but it didn't work.

var select = localStorage.getItem("bookid");
var search = Apperyio("mobilesearchbar_282").val();
var cow = Apperyio("mobiletextinput_cowidd");
var sire = Apperyio("mobiletextinput_405sire") ;
var color = Apperyio("mobiletextinput_406color ");

return '{"$and":[{"Book":"'+select +'"},{"calf_id":"'+search +'"},{"cow_id":"'+cow+'"},{"sire":"'+sire+'"},{"color":"'+color+'"]}';

What I originally had is this and it worked the way it was supposed to. What it was supposed to do was based on what was selected in a menu (I think this is where the select variable come in) it would search for what was typed in the box. The problem is that it only searches with in one column, the calf_id column. I want it to search in other columns as well.

var select = localStorage.getItem("bookid");
var search = Apperyio("mobilesearchbar_282").val();

return '{"$and":[{"Book":"'+select +'"},{"calf_id":"'+search +'"} ]}';

Any idea what I did wrong?


How to use search to query multiple database columns

Posted: Tue Jan 13, 2015 5:59 am
by Yurii Orishchuk

Hi Ellen,

At first you should open browser debugger on network tab and find your list/query request.

Then open it and see what actually passed into "where" request parameter.

Only this fact(actual "where" parameter could give us any information about reason of your problem). Also please give us response of this request.

Regards.


How to use search to query multiple database columns

Posted: Tue Jan 13, 2015 5:42 pm
by Ellen Schlechter

How to use search to query multiple database columns

Posted: Sat Jan 17, 2015 1:35 am
by Ellen Schlechter

Did this help at all?


How to use search to query multiple database columns

Posted: Tue Jan 20, 2015 1:20 pm
by Ellen Schlechter

??


How to use search to query multiple database columns

Posted: Wed Jan 21, 2015 1:07 am
by Yurii Orishchuk

Hi Ellen,

As i can see - you pass incorrect values for fields thus you have empty result(no items).

Details: http://prntscr.com/5v1rfq/direct

Regards.


How to use search to query multiple database columns

Posted: Wed Jan 21, 2015 3:22 am
by Ellen Schlechter

This is the code that I have for it. Should I change what is between the + signs?? Image


How to use search to query multiple database columns

Posted: Fri Jan 23, 2015 5:54 am
by Ellen Schlechter

???


How to use search to query multiple database columns

Posted: Tue Jan 27, 2015 2:48 am
by Ellen Schlechter

?


How to use search to query multiple database columns

Posted: Tue Jan 27, 2015 3:29 am
by M&M

hi Ellen,

I think what happened was you missed the .val() when retrieving the values into the variables cow, sire and color.

For example

var cow =Apperyio('mobiletextinput_cowid').val();
var sire =Apperyio('mobiletextinput_405sire').val();
var color =Apperyio('mobiletextinput_406color').val();

Without that the variable will have a reference to the object itself but not the value of the object