我在我的 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
最佳答案
首先 - 看看这个答案,类似的问题: 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"
然后您就可以轻松查询居住在英国的男性。
顶部链接中描述的另一个选项是添加一个结合国家/地区和性别的键,然后查询此属性。
关于android - 在 firebase 上进行查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34045882/