Skip to content
Advertisement

How to get a child value if another child value matches in Firebase?

My Database Structure is:

JavaScript

In this structure, I need to get “ID” (which is autogenerated) as “ovxZPZeyy2VlZUP1K0vv9VtiThu1” if the “UserName” matches to “GokulNew1”. And I need to store the ID in String ID.

And My Code is,

JavaScript

Advertisement

Answer

To get the key of the node (ovxZPZeyy2VlZUP1K0vv9VtiThu1) if the “UserName” matches to “GokulNew1”, please use the following lines of code:

JavaScript

The result in the logcat will be:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement