2017-02-14 37 views
0

我想查詢我的數據庫來獲取所有具有child number > 7火力地堡orderByChild沒有得到結果

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

你傳遞'7'(帶引號),但存儲爲7值(不帶引號)。這意味着你正在比較字符串和數字,這是行不通的。

而是使用此:

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

謝謝!明白了.. –