Reputation: 2314
I am using the set method as following:
admin.firestore()
.collection('threads')
.doc(threadId)
.collection('posts')
.doc(postId)
.set(data);
Doing the following works, but it generates another document with the exact same id, and no data (just the sub-collection in it), rather than adding a sub-collection to the original document.
Here is a screenshot of my root collection (threads) after the set() method call :
The document with id in italic doesn't contain any data but a sub-collection (with the correct document).
What am I doing wrong here, and how can I ensure my actually existing document is updated ?
Also I applied the same method to create documents in my thread collection (db.collection('threads').doc(newThreadId).set(data)
) and worked like a charm, for both creating and updating existing documents.
Upvotes: 0
Views: 37
Reputation: 317692
If your code is still reading and writing document data as you expect, regardless of what you see in the console, then congratulations - you've found a bug in the Firebase console. It's highly unlikely that your code or the SDK is doing anything wrong.
I suggest contacting Firebase support and file a bug report with the steps you took that reproduce this situation.
Upvotes: 1