Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Deleting data from firebase after 50 messages

I want to ask how can we delete data from Firebase's real-time DB after a certain number of msgs using javascript.

The code:

function getData() {
      firebase.database().ref("/" + room_name).on('value', function (snapshot) {
            document.getElementById("output").innerHTML = "";
            snapshot.forEach(function (childSnapshot) {
                  childKey = childSnapshot.key;
                  childData = childSnapshot.val();
                  if (childKey != "Purpose") {
                        firebase_message_id = childKey;
                        message_data = childData;
                        
                        //Start code
                        named = message_data["name"];
                        message = message_data["message"];
                        like = message_data["like"];
                        timed= message_data['time']
                        
                 
                          row = "<h4> "+ named+"<b class='time'> "+timed+"</b>"+"</h4><h4 class='message_h4'>"+ message +"</h4><button class='btn btn-warning' id='"+firebase_message_id+"' value='"+like+"' onclick='updateLike(this.id)'><span class='glyphicon glyphicon-thumbs-up'>  Like: "+ like +"</span></button><hr>";
      document.getElementById("output").innerHTML += row;                      
                        //End code    
  var objDiv = document.getElementById("output");
  objDiv.scrollTop = objDiv.scrollHeight;

                  }
            });
      });
}
getData();
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!