Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

How to use search to query multiple database columns

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?

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

How to use search to query multiple database columns

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.

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

How to use search to query multiple database columns

Did this help at all?

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

How to use search to query multiple database columns

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.

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

How to use search to query multiple database columns

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

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

How to use search to query multiple database columns

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

Return to “Issues”