I want to sort a list in firebase realtime database using orderByChildValue(). But the value is inside an array.
How to do that?
Database
{
  "partners": [
    {
      "full_name": "Alex Smith",
      "partner_roles": {
        "role1": [
          {
            "latitude": 9.84945654,
            "locality": "location1",
            "longitude": 76.32834545
          },
          {
            "latitude": 9.81232145,
            "locality": "location2",
            "longitude": 76.34229345
          }
        ],
        "role2": [
          {
            "latitude": 9.84945654,
            "locality": "location1",
            "longitude": 76.32834554
          }
        ]
      }
    }
  ]
}
Here i want to return all the items role1/locality equals location2
i tried using:
database.child("partners")
            .orderByChild("partner_roles/role1/locality")
            .equalTo(location1)
But it returns empty and It returns items if the database is like:
{
  "partners": [
    {
      "full_name": "Alex Smith",
      "partner_roles": {
        "role1": {
          "latitude": 9.84945654,
          "locality": "location1",
          "longitude": 76.32834545
        },
        "role2": {
          "latitude": 9.84945654,
          "locality": "location1",
          "longitude": 76.32834554
        }
      }
    }
  ]
}
 
    