简体   繁体   English

如何从firebase实时数据库中检索数据使用时间戳?

[英]How to retrieve data from firebase realtime database use timestamp?

this is my db structure : https://drive.google.com/open?id=15067yFPeeGoQH9kaagw6vxw-zoDFXmBN 这是我的数据库结构: https//drive.google.com/open?id = 15067yFPeeGoQH9kaagw6vxw-zoDFXmBN

I want to retrieve data from the child "nilai" based on time using timestamp, then enter it into the highchart, I am confused by the code, is my code correct? 我想基于时间使用时间戳从孩子“nilai”中检索数据,然后将其输入高级图表,我对代码感到困惑,我的代码是否正确?

var startdate = 1552268459655;
var enddate = 1552268535866;
    firebase.database().ref().child("Perangkat2").child("hujan").child("2").child("hujanpermenit").child(data.key).orderByChild("timestamp").startAt(startdate).endAt(enddate).once('value').then(function(snapshot) {
snapshot.forEach(function(child) {
var childData = child.val();
var timestamps=child.val().timestamp;
var nilai=child.val().nilai;
   });
});

Try this code: 试试这段代码:

var startdate = 1552268459655;
var enddate = 1552268535866;
firebase.database().ref().child("Perangkat2").child("hujan").child("2").child("hujanpermenit").orderByChild("timestamp").startAt(startdate).endAt(enddate).once('value').then(function(snapshot) {
snapshot.forEach(function(child) {
var childData = child.val();
var timestamps=child.val().timestamp;
var nilai=child.val().nilai;
});
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM