【问题标题】:Doing queries on firebase在 Firebase 上进行查询
【发布时间】:2015-12-02 14:59:40
【问题描述】:

我在我的 android 应用程序中使用 firebase,但我遇到了问题。例如。我有这个条目

persons
    -kskhdhksdhh
        name:"Vladimir"
        age:"25"
        sexe:"M"
        country:"Russia"
    -jhgsdhghsgs
        name:"Victoria"
        age:"20"
        sexe:"F"
        country:"England"
    -zejhbshevzh
        name:"John"
        age:"44"
        sexe:"M"
        country:"England"

我想选择居住在英国的男性。知道我们不能做两个 orderby,我如何重新排列我的数据以到达那里

【问题讨论】:

标签: android request firebase firebase-realtime-database


【解决方案1】:

首先 - 看看这个答案,对于类似的问题: Query based on multiple where clauses in firebase

无论如何,您可以将国家/地区级别添加到您的数据结构中,因此您的数据可能类似于:

persons
    -Russia
       -kskhdhksdhh
           name:"Vladimir"
           age:"25"
           sexe:"M"
     -England
       -jhgsdhghsgs
           name:"Victoria"
           age:"20"
           sexe:"F"
       -zejhbshevzh
           name:"John"
           age:"44"
           sexe:"M"

然后您可以轻松查询居住在英格兰的男性。

顶部链接中描述的另一个选项是添加一个结合国家和性别的键,然后查询此属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 2017-12-21
    • 2019-10-03
    • 2018-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多