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

170
Vistas
Firestore, adding value to an existing array field

I want the new ph value to be added in the arraylist but instead, it keep updating the first value of the arraylist

my firestore

var insBtn = document.getElementById("InsBtn");

 async function AddDocument_CustomID() {
    var ref = doc(db,"pHvalue", "pH");

     await setDoc(
        ref, {
            pH: [pH.value]
        });
}


insBtn.addEventListener('click', AddDocument_CustomID);

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want to add a new unique value to the existing values in the pH array, you can use an array-union operation:

updateDoc(ref, {
    pH: arrayUnion(pH.value)
});

If you instead want to add a possibly non-unique value to the end of the pH array, you will instead have to:

  1. Load the document into your application and get the existing pH array from it.
  2. Add the new item to the end of the array.
  3. Write the entire array back to the database.
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