按名称检索对象的FIrebase会给出null结果

时间:2016-06-09 06:15:04

标签: firebase firebase-realtime-database

我有一个firebase数据库:

class MyComponent implements CanReuse {
  routerCanReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction) {
    return true;
  }
}

我想检索名字的记录=" Seema" 我正在运行以下查询:

contacts:{
         "123": {
                 "email": "priya@gmail.com",
                 "name": "Priya"
                 }
         "679": {
                 "email": "seema@gmail.com",
                 "name": "Seema"
                 }

         }

但是控制台输出为null:

  

匹配名称= Priya null的帐户

1 个答案:

答案 0 :(得分:2)

你可以试试这个:

var ref = new Firebase("https://teststack.firebaseio.com/contacts");

    ref.orderByChild('name').equalTo('Priya').once('value', show);

    function show(snap) {
      console.log(JSON.stringify(snap.val(), null, 2));
    }