Reputation: 6776
I have following database
-KYTfJZQbg0RVzHeecIS
createdAt: 1481204648530
message: "rgd"
read: false
reciever: "583d15cf45f3330807364c55"
sender: "58490e9945f33364ac6cd7b1"
updateAt: 1481204648654
Now I want to filter the result for "READ"==FALSE AND "SENDER"==58490e9945f33364ac6cd7b1
how can I achieve this?
Any help would be appreciated Thanks
EDIT :-
I am using this in android as
Query query = reference.orderByChild("read").equalTo(false)
.orderByChild("sender").equalTo(datum.getEmployer().getEmployerId());
it gave java.lang.IllegalArgumentException: You can't combine multiple orderBy calls!
Upvotes: 3
Views: 13102
Reputation: 2827
Multiple orderbychild() queries is not supported by firebase .
Now I want to filter the result for "READ"==FALSE AND "SENDER"==58490e9945f33364ac6cd7b1
Make a new key in your data i.e. READ_SENDER and combine data for both and use query like this -
-KYTfJZQbg0RVzHeecIS
createdAt: 1481204648530
message: "rgd"
read: false
reciever: "583d15cf45f3330807364c55"
sender: "58490e9945f33364ac6cd7b1"
read_sender : "false_58490e9945f33364ac6cd7b1"
updateAt: 1481204648654
Query query = reference.orderByChild("read_sender").equalTo("false_"+datum.getEmployer().getEmployerId());
Upvotes: 6
Reputation: 10330
Unfortunately this isn't straightforward using Firebase.....there's good example of doing something very similar in following video by Firebase guys (about 9 mins in) https://www.youtube.com/watch?v=sKFLI5FOOHs&list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s&index=4
Upvotes: 4