0
我查詢FB在我下面的函數:火力地堡ORDERBY查詢返回null
getLimit: function(artistId, limit) {
console.log(FBURL +
'songs?orderBy=\"artist_timestamp\"&startAt=\"' +
artistId +
'_\"&endAt=\"' +
artistId +
'_9999\"&limitToLast=' +
limit +
'');
ref= new Firebase(FBURL +
'songs?orderBy=\"artist_timestamp\"&startAt=\"' +
artistId +
'_\"&endAt=\"' +
artistId +
'_9999\"&limitToLast=' +
limit +
'');
console.log(ref);
ref.on('value', (snapshot) => {
console.log("hello");
var val = snapshot.val();
console.log(val);
});
results = $firebaseArray(ref);
results.$loaded().then(function() {
console.log("loaded record:", results.$id);
// To iterate the key/value pairs of the object, use angular.forEach()
angular.forEach(results, function(value, key) {
console.log(key, value);
});
});
return results;
}
當我看到我對第一console.log
我試圖通過複製和粘貼重現null
導致終端呼叫什麼網址在逐字參數new Firebase()
成捲曲要求如下:
curl "the-exact-url-except-add-dot-json"
這是我所傳遞給new Firebase()
的基本格式:
https://my-proj.firebaseio.com/songs?orderBy="artist_timestamp"&startAt="foo_"&endAt="foo_9999"&limitToLast=7
所以當我蜷縮
curl 'https://my-proj.firebaseio.com/songs.json?orderBy="artist_timestamp"&startAt="foo_"&endAt="foo_9999"&limitToLast=7'
它的工作原理,但是當我把前者URL的快照我在on('value')
回調
得到null
和我得到的結果,我希望這是一個對象song
鍵和對象。
然而,當我得到的ref
以及轉換爲firebaseArray
並調用回調$loaded
後兩個快照我得到在這兩種情況下null
。我不確定發生了什麼事情會使結果出現在終端中,但不在代碼中。