1

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?

1 Answer 1

1

You should do something like :

Query query = firebaseServices.getUserData();

query.orderByChild("groups/-L9Q5d3T_XBBQGJygGqJ/group_id").equalTo(groupWiseModel.getId())
Sign up to request clarification or add additional context in comments.

1 Comment

Exactly what I wanted. Thanks alot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.