[英]Firebase: startAt() is not filtering data stored with keys as hours since epoch
My data is stored with keys as hours since epoch.我的数据从纪元开始以小时为单位存储在密钥中。 I want to get only slice of the data - so for example I want to specify that I want all data starting at
453615
.我只想获取数据的一部分 - 例如,我想指定我希望所有数据都从
453615
开始。
So far I got this code:到目前为止,我得到了这段代码:
this.dbService.databaseRef.child('dev_trends/' + this.deviceUid)
.orderByKey()
.startAt('453615')
.get().then(dataTrends => {
const data = dataTrends.val();
console.log(data);
});
With the code above I get this results in my console:使用上面的代码,我在我的控制台中得到了这个结果:
My data model looks like this:我的数据 model 如下所示:
I create the databaseRef variable inside a service with this code:我使用以下代码在服务中创建 databaseRef 变量:
constructor(private db: AngularFireDatabase) {
//Set what happens when we read all devices
this.databaseRef = db.database.ref(); //Create databaseReference
}
Json of my data:我的数据 Json:
{"dev_trends" : {
"-MkMxxZXXzmKclgeGPde" : {
"H" : {
"453614" : "50;45",
"453615" : "50;50",
"453617" : "50;55",
"453630" : "51;60"
},
"T" : {
"453614" : "24;18",
"453615" : "23;17",
"453617" : "23;15",
"453630" : "22;10"
}
}
}}
Find out where the problem was:找出问题出在哪里:
startAt()
method was filtering data with keys H
and T
and not the lists of data inside those keys. startAt()
方法使用键H
和T
过滤数据,而不是这些键中的数据列表。 New data model:新数据 model:
Additional info:附加信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.