'how to run a query with "multiple orderbychild" in realtime database on firebase v9 not v8 [duplicate]

example :

"USA": {
  "-N0QVhkDUxgrHQhS15B7": {
    "State" : 0,
    "Date" : 20220427
  "-N0Vut4beTbYTXihw0KM": {
    "State" : 1,
    "Date" : 20220429
  },
  "-N0W4oWNsgnKYmjPAfhl": {
    "State" : 1,
    "Date" : 20220427
  },
},

above is database for example.

var ordersRef = query(
  ref(db, "StoreOrders/" + "USA"),
  orderByChild("State"),
  equalTo(1),
  orderByChild("Date")
);

I had run this above query. but, below error was occured

Uncaught (in promise) Error: orderByChild: You can't combine multiple orderBy calls. Reference impl.ts:164

how can i solve this problem? this verion is 9. Please let me know correct answer.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source