I have a Firebase collection named Rooms
and sub-collection messages
but when I try to retrieve the Rooms
collection it only returns the generated document IDs.
I have tried to retrieve it with this code. but it only retrieves the generated document IDs.
final data = await firestore.collection('Rooms').get();
for (var doc in data.docs) {
final event = doc.id;
print(event);
}
2
Answers
Thanks a lot to those who give me the response to my question. I got the answer from this post.
The data I added to Firestore is displayed in italic
The italics style only means that under this document, there are other subcollections present. If you try to query such documents, you won't get a result, since such documents don't exist. So that document is displayed like that for two main reasons. You either deleted the document without deleting all the documents in all of their subcollections, or you didn't create it in the first place.
Try with this:
I am not sure which ID you want to access by the above code, if you created an
id
field manually, follow the below instructions.