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

194
Views
Adding a document in an subcollection in an already existing document | Firebase v9

I'm trying to add a document to a subcollection in an existing document (check code below). When the document is being updated, there is being added a completely new document with the same id, but the existing document is not updated. How can I add the following data below in the already existing document, instead of making a new one?

Code:

const docRef = doc(db, "users", data.id);
const colRef = collection(docRef, 'teams')
addDoc(colRef, {
   id: response.data.account.id,
   role: 'owner',
   uid: data.id,
});

Firebase firestore

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As suggested by @dharmaraj, the issue could be caused by a trailing whitespace so a good way to check could be printing the data.id field using console.log('${data.id}').

This was confirmed by the OP and after the fix everything worked.

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!