I am new to using Firebase and NoSQL, I'm using it with AngularJS and I am having issues with querying references/"joins", I believe I have structured the tables as recommended. I have a Players table and a Groups table a couple of example objects below -
Players Table -
P1 : {Name: 'Tobias', Age: 24, Groups: {GroupA: true}, Scores: {S1: true}}
P2 : {Name: 'Josh', Age: 22, Groups: {GroupA: true}, Scores: {S2: true}}
Groups Table -
GroupA : {Name: 'Group A', Players: {P1: true, P2: true}}
Scores Table -
S1 : {Score: 5, PlayerId: P1}
S2 : {Score: 3, PlayerId: P2}
Now I want to get all of the Players in GroupA, I do the following.
Players
.orderByChild('Groups/GroupA')
.equalTo(true)
.on('value', function(snapshot){
$scope.myPlayers = snapshot.val();
})
I now have my P1 and P2 player objects but I also want to get their associated scores as part of their object, this is where I am stuck. Is there a simple way to do this? If anyone could explain the next step it would be great.