Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

324
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda