0

I'm sending data to Firestore and I recognised that I can't read the documents I created.

I noticed that the documents IDs are printed out in italic.

I searched online then and found out that there may be something to do with the previous cancellation of the document itself and the retainment of sub-collections of that document.

I don't know If I'm doing something wrong in when setting the data so that I can't read the documents. This is how I set up the data:

guard let uid = Auth.auth().currentUser?.uid else { return }
    let db = Firestore.firestore().collection("Showcases").document(uid).collection("Showcase")
    
    

    let data = ["value1" : value1,
                "value2" : value2 ,
                "value3":value3,
                "value4": value4, 
                "value5": value5] as [String : Any?]
    db.document("\(index)").setData(data as [String : Any])
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
StackGU
  • 868
  • 9
  • 22
  • What line in the code you shared doesn't do what you expect it to do? – Frank van Puffelen Nov 30 '20 at 22:39
  • I actually don't know why the document I create (using this lines of code) is marked in italic, and so I don't know If I'm doing something wrong in writing the data in this manner – StackGU Nov 30 '20 at 22:59
  • The `/Showcases/$uid` document is marked in italic, because you didn't actually create that document. Instead you created a document in the `Showcase` subcollection, and *that* is the reason the console needs to show `/Showcases/$uid`, which it indicates by showing the ID in italic. This doesn't mean you're doing anything wrong, so it might be worth if you describe what problem you have due to the document ID showing in italics. See https://stackoverflow.com/questions/48137582/firestore-db-documents-shown-in-italics – Frank van Puffelen Nov 30 '20 at 23:17
  • Ok thank you, now is a little more clear, the problem I'm facing is that I can't read the documents inside the collection ```/Showcases/$uid``` I want to be able t read them, do you suggest me to **first** create the document with some fake field and then add the subcollection? Because if the document is in italic I can't read it – StackGU Nov 30 '20 at 23:26
  • 1
    Yup, that is the common workaround indeed. In fact, I just added an explicit instruction for that to the linked answer. – Frank van Puffelen Nov 30 '20 at 23:38

0 Answers0