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

107
Vistas
updating and existing object in firestore database?

In the following example I am updating 2 things. The first thing is an existing array in the db, and the second thing is an existing object. The array pushing is working as it should, but the object has an issue. I mean is there an equivalent for array union to object?

   // Doc model current state before the incoming update.
   data 
   {items :[]}
   {lists : {}}
   
   
   const addObjToClientsArr = async () => {
      const docRef = doc(db, 'data', _authContext.currentUser.uid);
      const payload = selected;
      // Array
      await updateDoc(docRef, { items: arrayUnion(payload) });
      // Obeject
      const payload2 = {[context.id]: [
            { a : 1 },
          ]}
        
       updateDoc(docRef, {
        lists: {
         payload2
      });
    };
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It sounds like you want to update a field inside a nested object, which you can do with:

const path = `lists.${context.id}.a`;
await updateDoc(docRef, {
  [path]: 1
})
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