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

196
Vistas
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 Respuestas
Responde la pregunta

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 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