I have a subcollection of comments for the posts in a comments collection. However, how do I create a field (please, refer to the image) automatically?
I can create field manually from firestore console. But, I am not sure how to call it in the code. I cannot find it online. Without the field my subcollection document says:
This document does not exist, it will not appear in queries or snapshots
I use commentsRef().doc(widget.post.postId).collection('comments).set({data})
to create a comment, but how would I create a 'blahblah' field for the doc in sub-collection?
Thanks!
CodePudding user response:
Your code is fine but you are trying to add field inside a collection which is not possible but just update your code to the following and it should work
commentsRef().doc(widget.post.postId).set({
'field': 'blahblah'
}).then((value) {
print('Document Updated');
});