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

326
Views
Firebase set(),push(),child() features

I am writing comments to movies. But with this code i just can add one comment. When i add second comment, the first comment changes with the second one. But i want to add more comments for my movie. How can i achieve that? (show variable is my movie's id. My movie's id is one.) The code is:

 btnComment.addEventListener('click',(e)=>{
                var movieComment = document.getElementById('textComment').value;
                set(child(firebaseRef, 'Movies/'+ show + '/Comments/'), {
                movieComment: movieComment
                });
      });

My Firebase that i stored some movies enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to keep a list of nodes in Firebase, consider using the push() method. To add a comment to the list with that:

push(child(firebaseRef, 'Movies/'+ show + '/Comments'), movieComment})

So we call push instead of set here, which generates a new child node with a unique ID under Comments.

Also see the Firebase documentation on adding a child node to a list and this classic blog post: Best Practices: Arrays in Firebase.

about 4 years ago · Juan Pablo Isaza Report
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!