Anters Bear
Anters Bear

Reputation: 1956

Getting list of names of documents in a collection Google Firestore

I would like to get the names of all the documents inside a collection. I'm able to get the data, but I can't seem to find the value of the name stored anywhere.

let docRef = db.collection("selections").document("0").collection(Auth.auth().currentUser!.uid)
docRef.getDocuments { (docs, error) in
    for d in docs!.documents {
        print(d.data())
    }
}

Upvotes: 0

Views: 31

Answers (1)

Anters Bear
Anters Bear

Reputation: 1956

Not sure why I couldn't figure this our earlier.

let docRef = db.collection("selections").document("0").collection(Auth.auth().currentUser!.uid)
docRef.getDocuments { (docs, error) in
    for d in docs!.documents {
        print(d.documentID)
    }
}

Upvotes: 1

Related Questions