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

290
Vistas
How to update document data which located inside a subcollection in Firebase & Nuxt

My firestore structure

Subwork Package (collection)
        - UID (document)
                - Subwork Registration (subcollection)
                        - Doc unique ID (document)
                                - data etc etc
        - UID (document)

I have a table that displays all the documents that I have, inside the "Subwork Registration" subcollection.

//LOAD DATA TO TABLE IS SUCCESS
initializeTable() {
    this.SubworkTable = [];
    firestore
        .collectionGroup("Subwork Registration")
        .get()
        .then(querySnapshot => {
            querySnapshot.forEach(doc => {
                this.SubworkTable.push({ ...doc.data(), id: doc.id })
            })
        })
}

Then, I will pick one of the docs and edit/update its content from the list of docs that shows on the table. But when I do as below, I got into an error .collectionGroup("").doc("") is not a function kind of error

data: () => ({
    editedItem: {
        v-model: '',
        v-model: '',
        // etc etc
   }
})

//METHODS: {}
UpdateTable() {
    var data = {
        //
    };
    firestore
        .collectionGroup("Subwork Registration")
        .doc(this.editedItem.id)
        .update(data)
        .then(() => {
            //
        })

}

I do take note that we cannot update or set if we do .collectionGroup("Subwork Registration").doc() but Im not sure how to do it the right way (to edit/update document inside a subcollection).

Any advice?

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

0

To write a document in Firestore you will need to know the complete path to that document.

I recommend either keeping the DocumentReference if you can (as that already contains the entire path to the document), or alternative store the doc.ref.path for each document instead of doc.id as you do now.

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