This is a follow up question to Firebase - proper way to structure the DB
I have the following DB structure:
\"artists\" : {
\"-KKMkpA22PeoHtBAPyKm
You can get the Keys with the help of Dictionary itself.
Database.database().reference().child("artists").observe(.value, with: { (snapshot) in
if snapshot.exists() {
if let artistsDictionary = snapshot.value as? NSDictionary {
for artists in artistsDictionary.keyEnumerator() {
if let artistsKey = artists as? String {
print(artistsKey) // Here you will get the keys.
}
}
}
} else {
print("no data")
}
}) { (error) in
print(error)
}