Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!