我想筛选Firebase
中的数据。我有一些疑问,但我无法按照我的要求过滤数据。
数据:在Firebase中过滤数据(使用复杂查询)android
{
"messages": {
"Data_1": {
"Inner_3": {
"Text": {
"-Kqgd2_QSi5HIlyH6Om3": {
"date": 1501840029764,
"text": "hi"
},
"-Kqgd6zZf51AdKNPrsX8": {
"date": 1501840047829,
"text": "hello"
}
}
}
},
"Data_2": {
"Inner_2": {
"Text": {
"-Kqm5GijxFT54wZRHIJj": {
"date": 1.501931572192E9,
"text": "hi"
},
"-Kqm5YohOG1cFWO-WNGc": {
"date": 1.501931646257E9,
"text": "test"
},
"-Kqm6935IY8Ddj20Z3TN": {
"date": 1.501931802871E9,
"text": "new message"
}
}
}
}
}
}
在上面的JSON,如果我通过Inner_3
然后应该返回下面的结果。它检查所有arrays
是否有Inner_3
可用,然后给我主层名称和最后TEXT
从Inner_3
。
{
"messages": {
"Data_1": {
"Text": {
"-Kqgd6zZf51AdKNPrsX8": {
"date": 1501840047829,
"text": "hello"
}
}
}
}
}
请帮我实现这个结果。
非常感谢。如果Data_2包含Inner_2和Inner_3两者,该怎么办?那么,我应该在Key中使用什么? –
这变成了一个分类问题。在这里看到我更长的答案:http://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value –
根据您的链接建议,我创建了不同的频道列表。 –