0
"-XSRdqutnYU9_idduFRs": {
"title": "Demo1",
"image":"url.png",
"demoAttributes": [
            {
                "key": "Property 1",
                "unitName": "cm",
                "value": 15
            },
            {
                "key": "Property 2",
                "unitName": "cm",
                "value": 54
            }
]
}

As above I have an output as a result of the get request. I am using Firebase Rest Api. I want Property 1 to list those above 10. How can I do that?

dinosaurs.json?orderBy="dimensions/height"&startAt=3

It says in the Firebase documents that it can access sub-items in this way. For these objects. How do we do this for array?

Gurkan T
  • 198
  • 2
  • 14

1 Answers1

0

Firebase Realtime Database queries function on a flat list of nodes. The value to order/filter on must exist at a fixed path under each direct child node of the location you query.

So in your JSON you can query the parent node of "-XSRdqutnYU9_idduFRs on title and image, but you can't query on key, unitName or value, since those are at a dynamic path under each child node.

In other words: your current data structure makes it easy to look up the demo attributes for a specific node. But it does not make it easy to find the nodes for a specific demo attribute. To allow that, you'll typically want to add an additional data structure, where you map from the demo attributes back to the nodes.

For an example and longer explanation on this, see Firebase query if child of child contains a value

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807