我的火力DATABSE如下:是否有可能迭代两个数组来匹配值?
Users {
askdfasdf: John: {
Selection: [1,2,3]
},
fasfadffe: Mark: {
Selection: [1,2,4]
}
}
Players {
{
name: 'Messi',
agility: 90,
id: 1
},
{
name: 'Beckham',
agility: 54,
id: 2
},
{
name: 'Rooney',
agility: 10,
id: 3
},
{
name: 'Neymar',
agility: 84,
id: 4
}
}
数据库节点通过下面的代码带入范围:
var ref = firebase.database().ref("players");
var ref3 = firebase.database().ref("users").child(uid).child("total");
$scope.players = $firebaseArray(ref);
$scope.selection = $firebaseArray(ref3);
是否存在通过搜索两个数组的方式来itereate或环匹配值?具体来说,是否有一种方法可以通过“players”数组来循环搜索id
与“selection”数组中的数字相匹配的球员。
最终目标是让每个客户的选择在选择完成后反映在页面上。
我DATABSE安全规则如下:
{
"rules": {
"players":{
".read" : "auth != null",
".write" : "auth != null",
".indexOn": "id"
}
}
}
我试图遍历每个选择如下:
$scope.getSelectedPlayers = function(){
for (let i = 0; i<$scope.selection.length; i++){
return $scope.selection[i];
var ref=
firebase.database().ref("players").orderByChild("id").equalTo($scope.selection[i]);
}
但这并没有工作
@NinaScholz对不起你能详细谈谈那一点?我不太确定这是什么意思? –
对不起,这只是想。 –