2

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.

Community
  • 1
  • 1
ThatTobMate
  • 163
  • 1
  • 8

1 Answers1

0

To join data, you may need to use firebase-util library. You can even create your own data for test before you implement it in your app. All you need is to follow this link: http://firebase.github.io/firebase-util/#/toolbox/NormalizedCollection/

Hope that helps! Let me know if things work as expected :)

ALI MAKEEN
  • 403
  • 3
  • 8