I have a simple problem. I have an existing document in cloud firestore and I simply want to add a subcollection to this document and add a document to this subcollection.

The following is my code for what I believe should do the job, but unfortunately doesn't. Also I dont get any errors.

var ref: DocumentReference? = nil
ref = db.collection("users").document("John").collection("newSubcollection").addDocument(data: [
                        "age": 25
                    ]) { error in
                        if let err = err {
                            print("Error adding subcollection: \(err)")
                        } else {
                            print("subcollection added with ID: \(ref!.documentID)")
self.dismiss(animated: true, completion: nil)


The message I get is that it succesfully created the subcollection, but I dont see it. What is going wrong?

0 Answers