如何在我的firebase数据库中获取整个JSON树中的节点?

时间:2017-05-16 11:21:02

标签: javascript angularjs firebase web-applications firebase-realtime-database

我的网络应用程序基于足球联赛。我有一个Javascript对象数组。每个玩家都是阵列中的一个对象:

 $scope.players = [
   {name : "Yasin 'YB' Amusan", Team : "Industry", price: 8000000, position: 'forward', image: src='http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png'},
   {name : "Hassan 'Hasi' Akinyera", Team : "Industry", price: 5000000, position: 'defender', image: src='http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png'},
   {name : "Femi 'Fabio' Awoniyi", Team : "Industry", price: 9000000, position: 'defender',image: src='http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png'},
   {name : "Deji 'Dej' Awoniyi", Team : "Industry", price: 7000000, position: 'forward',image: src='http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png'},
   {name : "Koye 'K10' Kekere-Ekun", Team : "Industry", price: 9000000, position:'midfielder', image: src='http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png'},
   {name : "Teni 'Teezee' Zacchaeus", Team : "Industry", price: 6000000, position:'hybrid', image: src='http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png'},
   {name : "Bolaji 'Boj' Odojukan", Team : "Industry", price: 7000000, position:'forward', image: src='http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png'}
 ];

然而,当玩家数量增加到47左右时,我决定使用firebase作为我的后端。所以我制作了播放器的JSON文件并将其导入firebase数据库:

 {
"players" : [
   {"name" : "Yasin 'YB' Amusan", 
    "Team" : "Industry",
    "price": 8000000, 
    "position": "forward", 
   "image":"http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png", 
    "goals": 0, 
    "assists" : 0, 
    "Y" : 0, 
    "R" : 0},
   {"name" : "Hassan 'Hasi' Akinyera",
    "Team" : "Industry", 
    "price": 5000000, 
    "position": "defender",
    "image":"http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png",
    "goals": 0, 
    "assists" : 0,
    "Y" : 0,
    "R" : 0},
   {"name" : "Femi 'Fabio' Awoniyi",
    "Team" : "Industry",
    "price": 9000000,
    "position": "defender",
    "image":"http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png",
    "goals": 0, 
    "assists" : 0, 
    "Y" : 0, 
    "R" : 0},
   {"name" : "Deji 'Dej' Awoniyi",
    "Team" : "Industry",
    "price": 7000000,
    "position": "forward",
     "image":"http://res.cloudinary.com/deji/image/upload/v1489787662/blank_photo_mqvivv.png",
    "goals": 0, 
    "assists" : 0, 
    "Y" : 0, 
    "R" : 0}
  ....etc
   ]
   }

列出的玩家可供用户选择使用:

var ref = firebase.database().ref().child('players');
 $scope.players = $firebaseArray(ref);
  console.log ($scope.players); 

当每个用户选择他们想要的玩家时,它会被发布到"用户"下的子节点。节点称为游戏周1'并根据每位球员的表现/统计数据分配各自的分数。

我的问题

我的问题是如何在“玩家”中更新玩家统计信息。数据库中的节点使其在“游戏周”中更新。每个用户在"用户"中的选择下的子节点节点

0 个答案:

没有答案