Firebase orderByChild() works well when child properties have names, so that with data like this:
groups
<groupID>
groupStatus: "Active"
is is easy to get the groupIDs of the groups with "Active" status by this:
var ref = "http://myFirebase.firebaseio.com/groups";
ref.orderByChild("groupStatus").equalTo("Active").on("child_added", function(snapshot) {
console.log(snapshot.key());
});
But I have firebase data of groups and the members of those groups in the following form:
groups
group123
member404: true
member503: true
...
group124
member503: true
member221: true
...
I need to generate a list of all the memberIDs who are "friends" of a particular member, defined as being in at least one group in common with them. For member 503, you would think this would be a orderByChild() opportunity. But since the memberIDs are keys nested under the groups, what would the syntax be?
Something like:
ref.orderByChild(???).equalTo("member503")
Of course, I could get all the members of all the groups into an array locally, but surely there is a way to get firebase to do this for me?