【发布时间】:2017-09-24 02:41:59
【问题描述】:
我开始学习 JavaScript 已经几个月了,因为我是一名 IOS 开发人员,我也更喜欢 Firebase 作为我网站的后端。
所以在今天的实践中,我曾经读取Firebase数据并提醒自己,我使用了这段代码,
注意:这些代码只是示例,在我的工作中使用,它正式来自 Firebase 的文档。
var query = firebase.database().ref("users").orderByKey();
query.once("value")
.then(function(snapshot) {
snapshot.forEach(function(childSnapshot) {
// key will be "ada" the first time and "alan" the second time
var key = childSnapshot.key;
// childData will be the actual contents of the child
var childData = childSnapshot.val();
alert(key); // also tried the (key.value); as well
});
【问题讨论】:
标签: javascript firebase firebase-realtime-database