0

I wanted to save Firebase data via the admin panel. I have everything set up and ready to save data. When I save the data, this data appears in italics in the Firestore and I cannot pull this data from my normal application. What should I do to solve this? Thanks.

I leave images that I can show as examples.

Here, I throw the data I get into a HashMap and send it to the function to save it in Firestore, it enters the Firestore, but this record is italicized and I cannot read this data. The problem is right here. (Example 1)

enter image description here

When I try to save the data manually on the Firestore, it records without any problems and I can read this data from the application. (Example 2, Example 3)

enter image description here

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
Erhan
  • 25
  • 3

1 Answers1

4

The document with is listed in italics ("Example 1") is not actually a document that exists in the collection. 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 because of 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. When you see that, it just means that you reserved a document ID for later use. Meaning that such documents will remain visible in the console because you might want to navigate into their subcollections.

One thing to remember, in Firestore documents and their corresponding sub-collections don't work like filesystem files and directories on the disk. If you create a sub-collection under a document, it doesn't implicitly create any parent documents. Sub-collections are not tied in any way to a parent document.

If you want to correct that, you have to write at least a property that can hold a value under the "Example 1" document. Even a null value will be sufficient. On the other hand, if you delete a document, its sub-collections will continue to exist.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193