Firebase查询不允许订购多个属性? [英] Firebase query does not allow order on multiple properties?
问题描述
pre $最近
| _UniversitId
| _objectiId1
| | _ userId:1
| | _ timestamp:143242344
| _objectiId2
| _ userId:1
| _ timestamp:143243222
我的查询路径是 http://firbasedbname.com/Recent/UniversityId
。我需要获取userId id等于1的条目,并按照时间戳设置。我尝试了以下内容:
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ ;
这会正确提取我的用户。但有没有一种可能的方式来订购这个时间戳集。要做到这一点,我试着把另一个 queryOrderedByChild
。但它说只能使用一次。我怎样才能解决这个问题?
queryOrderedByChild只能使用一次。
解决方法将是
| _objectiId1
| | _ userId:1
| | _时间戳:143242344
| | _ userId_timestamp:1_143242344
| _objectiId2
| _ userId:1
| _ timestamp:143243222
| _ userId_timestamp:1_143243222
然后试试:
FIRDatabaseQuery * query = [[ firebase queryOrderedByChild:@userId_timestamp] queryEqualToValue:@1_143242344];
检查 https://youtu.be/sKFLI5FOOHs?t=541
另一种方式这样做是:
pre code $ | bob $ | b $ | $ userId1:
| | _ objectId11:143242344
| | _ objectId12:143243222
| _ userId2:
然后
查询路径是 http://firbasedbname.com/Recent/UniversityId/userId1
然后按价值排序
I'm trying to fetch some data from firebase. In my object, I have
Recent
|_UniversitId
|_objectiId1
| |_ userId:1
| |_ timestamp:143242344
|_objectiId2
|_ userId:1
|_ timestamp:143243222
My querying path is http://firbasedbname.com/Recent/UniversityId
. I need to fetch the entries which are userId id is equal to 1 and order that set by timestamp. I tried the following,
FIRDatabaseQuery *query = [[firebase queryOrderedByChild:@"userId"] queryEqualToValue:@"1"];
This fetches my the users correctly. But is there a possible way to order this set by timestamp. To do that I tried by putting another queryOrderedByChild
. But it says it can be used only one time. How may I fix this?
queryOrderedByChild can be used only once. a workaround would be
|_objectiId1
| |_ userId:1
| |_ timestamp:143242344
| |_ userId_timestamp:1_143242344
|_objectiId2
|_ userId:1
|_ timestamp:143243222
|_ userId_timestamp:1_143243222
Then try :
FIRDatabaseQuery *query = [[firebase queryOrderedByChild:@"userId_timestamp"] queryEqualToValue:@"1_143242344"];
check this out https://youtu.be/sKFLI5FOOHs?t=541
another way to do it would be :
|_objectiId1
|_ userId1:
| |_ objectId11:143242344
| |_ objectId12:143243222
|_ userId2:
Then
querying path is http://firbasedbname.com/Recent/UniversityId/userId1
and then order by value
这篇关于Firebase查询不允许订购多个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!