javascript - Getting Firebase data of last 24 hours - Stack Overflow

I'm trying to get Firebase data of the last 24 hours. Actually I have this query:var ref = firebas

I'm trying to get Firebase data of the last 24 hours. Actually I have this query:

var ref = firebase.database().ref().child("datos").child("pedidos").child("nuevos");

How I can do that?

I'm trying to get Firebase data of the last 24 hours. Actually I have this query:

var ref = firebase.database().ref().child("datos").child("pedidos").child("nuevos");

How I can do that?

Share Improve this question edited Jan 19, 2018 at 0:04 Frank van Puffelen 601k85 gold badges890 silver badges860 bronze badges asked Jan 18, 2018 at 21:57 FabricioFabricio 3161 gold badge2 silver badges12 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 10

use orderByChild method on the timestamp child (or what ever you use store the time ), and startAt to get the data only that before 24 hours

let before24Hour = new Date().getTime() - (24 * 3600 * 1000);
firebase.database().ref().child('datos/pedidos/nuevos').orderByChild('time').startAt(before24Hour).on('value' , function(snap){
    console.log(snap.val());
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744281904a4566609.html

相关推荐

  • javascript - Getting Firebase data of last 24 hours - Stack Overflow

    I'm trying to get Firebase data of the last 24 hours. Actually I have this query:var ref = firebas

    8天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信