i am new Firebase. I want to delete data if they are older than 14 days. I am storing timestamp when create data. I have read below answer of Frank, but i can’t implement to my need. Need Help.
Delete firebase data older than 2 hours
Here is what i have done yet
let now = Date.now();
let cutoff = now - 1587706383; //14 timestamp
console.log(cutoff)
firebase.database().ref('usuario',).on('value', dataSnapshot =>{
dataSnapshot.forEach(user =>{
user.child('eventos').forEach(evento =>{
if (evento.val().timestamp === cutoff){
evento.ref.remove()
}
})
})
});