【发布时间】:2017-07-27 11:23:21
【问题描述】:
我每分钟都在存储用户的lat, lng, timestamp。
我只想读取基于timestamp 的部分数据。我试过下面的查询,没有用。还要检查我的示例数据库的附件。
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 之间的行。
我的 Firebase 规则如下所示
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"user-locations":{
"$uid": {
".indexOn": "timestamp"
}
}
}
}
【问题讨论】:
标签: javascript html firebase firebase-realtime-database