0

I have a data structure like this:

UserOrders
   ---- UserId1
          ----OrderId1
                 ----...
                 ----status: pending
                 ----...
          ----OrderId2
                 ----...
                 ----status: fulfilled
                 ----...
   ----UserId2
          ----OrderId3
                 ----...
                 ----status: pending
                 ----...

From UserOrders, I want to get all the orders that are pending.

firebaseAdmin.database().ref("UserOrders").orderByChild("...??...").equalTo("pending");

Is this possible in Firebase, without making any changes to the data structure?

Thanks.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
SKT
  • 271
  • 4
  • 15

1 Answers1

2

No, you can't query across multiple levels of unknown keys. You can only query using field values that are all children of the same immediate parent. So, you could find all the orders for a particular user, but you can't find all the orders for all the users that match.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441