我每分钟都会存储用户的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
查看我的更新回答 –