我每分鐘都會存儲用戶的lat, lng, timestamp
。 我想根據timestamp
只讀取部分數據。我試過下面的查詢,沒有工作。同時檢查我的示例數據庫的附件。Firebase請求的行數範圍
function queryLocations(){
var ref = firebase.database()
.ref('user-locations/' + currentUID)
.orderByChild('timestamp')
.startAt('1501061958000')
.endAt('1501062154000')
.on("child_added",function(data){
c = c+1;
locationCountElement.textContent = '' + c;
});
firebaseLocRef = ref;
}
所以,我startTimestamp
和endTimestamp
作爲輸入。我只需要timestamp
startTimestamp
和endTimestamp
之間的行。
我火力的規則是這樣的
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"user-locations":{
"$uid": {
".indexOn": "timestamp"
}
}
}
}
我試過這個。沒有運氣。請檢查我更新的問題。 – Sundeep1501
如何索引時間戳? Firebase查詢需要將其編入索引。 – Sundeep1501
查看我的更新回答 –