Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Firebase data of last 24 hours

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?

like image 736
Fabricio Avatar asked Jan 18 '18 21:01

Fabricio


People also ask

How to read data from Firebase Realtime Database?

Firebase Realtime Database is a NoSQL cloud-hosted real-time database from Google. When it comes to reading data from Firebase Realtime Database, there are two options available. The first one is to read the data using a persistent listener, meaning that we’ll always be in sync with the Firebase servers, or we can read the data only once.

How do I monitor my Firebase Database usage?

Monitor your database usage and check your plan's limits from the Usage tab in the Firebase console. You can check usage over the current billing period, the last 30 days, or the last 24 hours. Firebase shows usage statistics for the following limits:

How long does it take to update Firebase plan limits?

It may take up to 15 minutes to update your plan limits in the Firebase console. Monitor your database usage and check your plan's limits from the Usage tab in the Firebase console. You can check usage over the current billing period, the last 30 days, or the last 24 hours.

What is Firebase and why is it so popular?

The feature for which Firebase is famous is for its Firebase Realtime Database. By using Firebase Realtime Database in your app you can give live data updates to your users without actually refreshing your app.


1 Answers

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());
});
like image 186
Ali Faris Avatar answered Oct 19 '22 22:10

Ali Faris