Firebase orderByChild没有得到结果

时间:2017-02-14 01:24:17

标签: javascript firebase firebase-realtime-database

我正在尝试查询我的数据库以获取具有child number > 7

的所有日期
this.extra = function() {
    refer = ref.child(slot);
    refer.orderByChild('number')
         .startAt('7')
         .once('value')
         .then(function (snapshot) {
             console.log(snapshot.key());
         });
}

但是我得到了无效结果,知道为什么?

A look at firebase database

1 个答案:

答案 0 :(得分:1)

您正在传递'7'(带引号),但其值已存储为7(不带引号)。这意味着您需要比较字符串和数字,这将无法正常工作。

而是使用它:

ref.child(slot)
   .orderByChild('number')
   .startAt(7)
   ...