0

I have the following Data Structure and I'm using Firebase Real Time Database with the REST API.

each post has an ID (1234, 2341, 3412 and 4123 (will be more as the app is used)). each post has an isActive key which is set to false (if its deleted or replies are closed), true if it accepts replies, location (App1 or App2), username for the author and the amount of replies.

I tried getting the posts that has isActive set to true, location set to App2 and username set to cherries. the keys and values can be changed over time such as I might want to get the posts with the exact same configuration but with username set to apples.

when I tried making a request to the URL below, it only returns the posts with IDs 2341 and 3412. after some more testing, I found out that it only filters out based on the first parameter and ignores the rest

The data is registered as strings, please dont ask me to remove "

URL: https://MyDatabaseInfo.firebasedatabase.app/MyData.json?auth=MyAuthKey&orderBy="isActive"&equalTo="true"&orderBy="location"&equalTo="App2"&orderBy="username"&equalTo="cherries"

{
   "1234":{
      "isActive":"false",
      "location":"App1",
      "replies":"10",
      "username":"cherries"
   },
   "2341":{
      "isActive":"true",
      "location":"App2",
      "replies":"7",
      "username":"cherries"
   },
   "3412":{
      "isActive":"true",
      "location":"App1",
      "replies":"6",
      "username":"apples"
   },
   "4123":{
      "isActive":"false",
      "location":"App2",
      "replies":"16",
      "username":"apples"
   }
}
  • 1
    Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. So you could create a single property for each child node like `isActive_location_ username: "true_App2_cherries"`, and then filter on that. For a longer example of this and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Jul 06 '23 at 11:46

0 Answers0