How to retrieve multiple keys in Firebase?
<p>Considering this data structure:</p>

<pre><code>{
    "users":{
        "user-1":{
            "groups":{
                "group-key-1":true,
                "group-key-3":true
            }
        }
    },
    "groups":{
        "group-key-1":{
            "name":"My group 1"
        },
        "group-key-2":{
            "name":"My group 2"
        },
        "group-key-3":{
            "name":"My group 3"
        },
        "group-key-4":{
            "name":"My group 4"
        },
    }
}
</code></pre>

<p>I could get the groups of a particular user with:</p>

<pre><code>firebase.database().ref('users/user-1/groups').on(...)
</code></pre>

<p>Which would give me this object:</p>

<pre><code>{
    "group-key-1":true,
    "group-key-3":true
}
</code></pre>

<p>So now I want to retrieve the info for those groups.</p>

<p>My initial instinct would be to loop those keys and do this:</p>

<pre><code>var data = snapshot.val()
var keys = Object.keys(data)

for (var i = 0; i &lt; keys.length; i++) {
    firebase.database().ref('groups/' + keys[i]).on(...)
}
</code></pre>

<p>Is this the appropriate way to call multiple keys on the same endpoint in Firebase?</p>

<p>Does Firebase provide a better way to solve this problem?</p>