Bru*_*uno 5 javascript firebase
我正在尝试使用promises从Firebase填充一些数据.这是DB结构:
- domain name(or something)
|--highscore
|--Foo: 50
|--Bar: 60
Run Code Online (Sandbox Code Playgroud)
代码:
var arr=[];
highscoreRef.child('highscore').once('value').then(function(snapshot) {
snapshot.forEach(function(data) {
arr.push({playerName: data.key(), score: data.val()});
});
}, function(error) {
console.error(error);
});
Run Code Online (Sandbox Code Playgroud)
我明白了 Uncaught Error: Query.once failed: Was called with 1 argument. Expects at least 2.
这是否意味着我必须向Foo和Bar添加至少2个属性?防爆.Foo = {playerName:name,score:50}
当前的数据库安排符合我的需求.