'How to get the name of child realtime database kotlin

I am trying to get the email (in this case [email protected]) however I don't see any method I can use that gets me the name of the child instead of the value.

https://i.stack.imgur.com/uzonn.png



Solution 1:[1]

In this case the email is the key of a nested object. You need to iterate over the collection documents and use their id as email

 firestore.collection("Users").get().result.documents.forEach { 
    Log.d("Key", "${it.key}")   
}

You can also use higher-order function to transform the documents, associate (using the email) and deserialize the data.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nikola Despotoski