如何使用js在firebase中搜索多个子onkeyup操作并使搜索更快?

时间:2017-01-26 06:43:23

标签: jquery firebase-realtime-database

我的客户有近20380条记录。我正在尝试使用以下代码执行搜索操作

$('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());
   });
});

以上代码正在运行。但我需要搜索多个字段。我的数据看起来像这样 enter image description here

我需要使用手机号码,姓氏,电子邮件等子级值进行搜索。我尝试多次使用orderByChild,如此

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());
   });

但这不起作用。第一个代码正在运行,但它真的很慢。有人可以帮我这个吗?提前谢谢。

0 个答案:

没有答案