Reputation: 2132
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
.
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:
I create the databaseRef variable inside a service with this code:
constructor(private db: AngularFireDatabase) {
//Set what happens when we read all devices
this.databaseRef = db.database.ref(); //Create databaseReference
}
Json of my data:
{"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"
}
}
}}
Upvotes: 3
Views: 124
Reputation: 2132
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.New data model:
Additional info:
Upvotes: 1