【发布时间】:2018-04-19 18:21:59
【问题描述】:
如何获取 Firebase (child) 中具有相同类别 ID 的所有元素?
getbyCateg: function(myCateg) {
var items = [];
FireBase.database().ref('product')
.orderByChild('category')
.equalTo(myCateg)
.once("value", function(snapshot) {
var key;
snapshot.forEach(function (childSnapshot) {
key = childSnapshot.key;
return true;
});
if (key) {
items.push(FireBase.database().ref('product').child(key).toString());
} else {
console.log("There is nothing of this category");
}
});
return (items);
.once 允许访问具有良好类别 ID 的第一个元素,但其他元素呢?我想创建一个包含所有这些元素的数组。
谢谢!
【问题讨论】:
标签: javascript firebase firebase-realtime-database vue.js promise