Reputation: 31
I am new to Firebase and basically I want to access the elements in the documents that are the id fields in each of the documents and I want to loop through them, is there any way I can retrieve and put that data in some kind of array and later loop through the array in swift? I am new here in StackOverflow please don't mind if I didn't ask the question properly. The link to the image how my database looks like is below please go through it.
So this is how my CloudFirestore Database looks like
Upvotes: 0
Views: 451
Reputation: 793
For This you have to setup Firebase Client SDK https://github.com/firebase/firebase-ios-sdk and after successfully setup
let db = Firestore.firestore()
db.collection("UniqueId's").getDocuments { (snapshot, error) in
if error != nil {
print(error)
} else {
for document in (snapshot?.documents)! {
if let id = document.data()["id"] as? String {
//Here you'll get your data
}
}
By the way I think your collection name may be a problem So if it is than change it's name to UniqueIds instead of UniqueIds
Upvotes: 1