Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda