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

181
Vistas
removing an object from firestore 9 array using arrayRemove()?

I am trying to remove an object from array in in firestore, but encountered an obstacle what are the requirement or the reference to do the removal ? does one key value in the object sufficient to do the remove or should the object by identical to the one that is getting removed ?

const deleteWeek = async () => {
        const docRef = doc(db, 'Weeks', id);
        await updateDoc(docRef, {
          weeks: arrayRemove({
            weekId: '7518005f-7b10-44b6-8e0a-5e41081ee064',
          }),
        });
      };
      deleteWeek();
    }

however week in data base looks like this

{name ,"Week 2"
days : [/*data all kinds*/]
weekId : "7518005f-7b10-44b6-8e0a-5e41081ee064"}

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

0

If it's an array of object, then you need to know the whole object to use arrayRemove() For example, if the a document looks like this:

{
  ...data
  weeks: [
    { 
      name: "Week 2",
      days: [/*data all kinds*/]
      weekId: "7518005f-7b10-44b6-8e0a-5e41081ee064"}
    }
  ]
}

You'll have to pass the entire week object in arrayRemove(). It might be better to store such data in sub-collections instead so you can query/delete a specific one.

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