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?
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.
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:
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.
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.
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());
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With