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

215
Vistas
Modify arrays in Firebase Firestore

The Firestore database has the following field structure

images: {day: ['url1', 'url2', 'url3,] night: ['url1']}

First I would like to be able to append a value to the arrays. Did try the following:

await updateDoc(doc(firestore, FIRSTORE_COLLECTIONS.IMAGES, id), {
        [folder]: {
          [key]: arrayUnion(fileUrl)
        }

It went to the right images: path but unfortunately this just created a new array with one value and removed the ones that where there.

Secondly. If I also like to be able to create a new array in the same path with a key that does not exist can this be done and how could that be solved with this setup any ideas?

dependencies: "firebase": "^9.1.1", "react": "^17.0.2"

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

0

This is what solved it:

 await updateDoc(ref, {
        [`${folder}.${key}`]: arrayUnion(fileUrl)
      });

Proper path where the arrayUnion methods is implemented. It also creates a new array if key does not exists, which is nice.

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