我如何获得此级别的密钥?

时间:2018-01-02 07:28:49

标签: android firebase firebase-realtime-database

enter image description here

您好,  我在Firebase中的查询中遇到此问题。 orderbykey()和orderbychild()不起作用。我如何查询这个?

欢呼,先谢谢。

代码段:

memorySlot1 = "one"
memorySlot2 = "two"

AssignSlot = function (memorySlot){
    return(
        {
            Slot : memorySlot,
            Content : (
                function(){
                    return (
                        window[
                            memorySlot
                        ]
                    )
                }
            )
        }
    )
}

ChangeSlotContent = function (obj,newContent){
    window[obj.Slot] =  newContent
}

console.log("______________")
var1 = AssignSlot("memorySlot1")
var2 = AssignSlot("memorySlot2")
var3 = AssignSlot("memorySlot2")
console.log(var1.Content() +" / "+ var2.Content() +" / "+ var3.Content()) // one / two / two

console.log("______________")
ChangeSlotContent(var2,"twotwo")
console.log(var1.Content() +" / "+ var2.Content() +" / "+ var3.Content()) // one / twotwo / twotwo

console.log("______________")
var1 = AssignSlot("memorySlot2")
console.log(var1.Content() +" / "+ var2.Content() +" / "+ var3.Content()) // twotwo / twotwo / twotwo

enter image description here

1 个答案:

答案 0 :(得分:0)

我刚刚在firebase上设计了我的JSON,如下图所示,这样我就可以简单地获得每个数据的唯一键enter image description here