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 01 Answer
Reset to default 10use 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
评论列表(0条)