【发布时间】:2017-02-03 23:35:39
【问题描述】:
我的 firebase 数据库中有这个结构
"metadata" : {
"2017" : {
"Februari" : {
"-Kc3BF0V1iLgtnI65LuR" : {
"date" : "2017-02-03T13:36:38.311Z",
"price" : 90
},
"-Kc3BF0V1xxfrtnI65OlS" : {
"date" : "2017-02-03T13:36:38.311Z",
"price" : 90
}
},
"Januari" : {
"-Kc3E5bpxpo3RpSHH3fn" : {
"date" : "2017-01-11T13:50:12.264Z",
"price" : 45
}
}
}
}
我想要在我的应用中实现的是显示这样的列表
> Januari
> - 45 (=price)
>
> Februari
> - 90 ()
> - 240
问题是我可以显示月份,但由于 firebase 创建的唯一 ID,我无法联系到孩子。
这是我从 firebase 取回的对象
e{
$$conf: Object
$id: "2017"
$priority: null
Februari: Object
-Kc3BF0V1iLgtnI65LuR: Object
date: "2017-02-03T13:36:38.311Z"
price: 90
Januari: Object
-Kc3E5bpxpo3RpSHH3fn: Object
date: "2017-01-11T13:50:12.264Z"
price: 45
}
我该如何处理?
【问题讨论】:
-
如何在没有 firebase 创建的唯一键的情况下输入 childNode?这实际上是我的问题:)
-
为什么不检索整个月份及其所有子项。将它们推送到一个数组并按以下方式对其子项进行排序: allChilds.sort((a, b) => a.price > b.price);
标签: angularjs firebase firebase-realtime-database angularfire