Reputation: 721
I am using Firebase in android.
I am having trouble in querying the below json.
I am having is an array of objects. A single object is posted below:
{
"currency" : "₹",
"groups" : {
"-L9Q5d3T_XBBQGJygGqJ" : {
"group_id" : "-L9Q5d3T_XBBQGJygGqJ",
"group_name" : "Group 1"
}
},
"groups_uid" : "-L9Q5d3T_XBBQGJygGqJ",
"name" : "Sample 1 ",
"number" : "1234567890",
}
orderByChild("groups_uid").equalTo("-L9Q5d3T_XBBQGJygGqJ")
works
But how to query orderByChild("groups").equalTo("-L9Q5d3T_XBBQGJygGqJ")
doesn't work.
Now I wanted to query like: Get all the objects having groups/{some id}/group_id = some value.
I need the objects the one I posted from array which matches groups/{some_id}
Can anyone help me with this query?
Upvotes: 1
Views: 708
Reputation: 1658
You should do something like :
Query query = firebaseServices.getUserData();
query.orderByChild("groups/-L9Q5d3T_XBBQGJygGqJ/group_id").equalTo(groupWiseModel.getId())
Upvotes: 1