0

I am having a customer nearly 20380 records. I am trying to perform search action using the following code

$('body').on('keyup','.client_txtbox',function(){
var srchTerm = $(this).val();
    var clientref = firebase.database().ref(client_root);

var escp = srchTerm+"\uf8ff";

clientref.orderByChild("client_firstname").startAt(srchTerm).endAt(escp).limitToFirst(5).once("value", function(snapshot) {
   console.log(snapshot.val());
   });
});

This above code is working.But I need to search multiple fields.My data looks like this enter image description here

I need to search using child values like mobile number,lastname,email. I tried using orderByChild multiple times like this

clientref.orderByChild("client_firstname").startAt(srchTerm).endAt(escp).orderByChild("client_mobilenumber").startAt(srchTerm).endAt(escp).limitToFirst(5).once("value", function(snapshot) {
   console.log(snapshot.val());
   });

But this is not working. The first code is working but its really slow. Can someone please help me with this? Thanks in advance.

Anu
  • 630
  • 1
  • 21
  • 45
  • Firebase Database queries can only order/filter by one child property. You may be able to combine the values you need, into a single property for searching properties. See http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Jan 26 '17 at 08:46
  • I tried this clientref.orderBy("client_firstname").startAt(srchTerm).endAt(escp).orderBy("client_lastname").startAt(srchTerm).endAt(escp); but this is not working for me. Is this code correct? @FrankvanPuffelen – Anu Jan 26 '17 at 08:54
  • I am getting this error clientref.orderBy is not a function. I couldnot get a solution so I made this a question. @FrankvanPuffelen – Anu Jan 26 '17 at 09:11
  • s/`orderBy`/`orderByChild`/g – Frank van Puffelen Jan 26 '17 at 09:13

0 Answers0