2016-06-18 123 views
1

我是使用Firebase和NoSQL的新用戶,我將它與AngularJS一起使用,並且在查詢引用/「連接」時遇到問題,我相信我已按照建議組織了表。我有一個球員表和組表一對夫婦的例子以下對象 -Firebase查詢參考/集合

球員表 -

P1 : {Name: 'Tobias', Age: 24, Groups: {GroupA: true}, Scores: {S1: true}}

P2 : {Name: 'Josh', Age: 22, Groups: {GroupA: true}, Scores: {S2: true}}

組表 -

GroupA : {Name: 'Group A', Players: {P1: true, P2: true}} 

成績表 -

S1 : {Score: 5, PlayerId: P1} 

S2 : {Score: 3, PlayerId: P2} 

現在我想讓GroupA中的所有玩家都做到以下幾點。

Players 
    .orderByChild('Groups/GroupA') 
    .equalTo(true) 
    .on('value', function(snapshot){ 
     $scope.myPlayers = snapshot.val(); 
    }) 

現在我有我的P1和P2播放器的對象,但我也希望得到它們的相關分數作爲其對象的一部分,這是我在哪裏卡住了。有沒有簡單的方法來做到這一點?如果任何人都可以解釋下一步,那就太好了。

回答