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,
});
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.