Max
Max

Reputation: 11

Firebase + REST API WEB Filtering by a specified child key

Filter by PC "genre" - works, example RPG below. Filter by "genre" Android - works, example RPG below. And to make a general request for the RPG "genre" on both PC and Android does not work. Firebase:

enter image description here

          "PC" : [ {
        "Games" : [ {
          "genre" : "rpg",
          "id" : "001",
          "name" : "2 peaks"
        }, {
          "genre" : "action",
          "id" : "002",
          "name" : "3 peaks"
        }, {
          "genre" : "quest",
          "id" : "003",
          "name" : "4 peaks"
        }, {
          "genre" : "rpg",
          "id" : "004",
          "name" : "5 peaks"
        } ],
        "description" : "PC"
      } ],
      "sourceId" : "1"
    }, {
      "Android" : [ {
        "Games" : [ {
          "genre" : "action",
          "id" : "001",
          "name" : "2 peaks"
        }, {
          "genre" : "quest",
          "id" : "002",
          "name" : "3 peaks"
        }, {
          "genre" : "rpg",
          "id" : "003",
          "name" : "4 peaks"
        }, {
          "genre" : "action",
          "id" : "004",
          "name" : "5 peaks"
        } ],
        "description" : "Android"
      } ],
      "sourceId" : "2"

Rules:

enter image description here

      "rules": {
    ".read": "true",
    ".write": "true",
    "Test": {
      ".indexOn": ["Games/genre"],
        "$uid": {
        "PC": {
          "$uid": {
            "Games": {
                ".indexOn": ["genre"]
            }
          }
        },
        "Android": {
          "$uid": {
            "Games": {
                ".indexOn": ["genre"]
            }          }        }    }    }

Request:

xxx.firebaseio.com/Test/0/PC/0/Games.json?orderBy="genre"&equalTo="rpg"

work!

Request:

xxx.firebaseio.com/Test/1/Android/0/Games.json?orderBy="genre"&equalTo="rpg"

work!

BUT the filter immediately on the PC and Android does not work:

xxx.firebaseio.com/Test.json?orderBy="Games/genre"&equalTo="rpg"

Please tell me how to make a request?

Upvotes: 1

Views: 226

Answers (1)

Moe
Moe

Reputation: 13

".indexOn": ["Games/genre"],

This is the issue. Im not sure what you're actually trying to get it to do here.. but you wouldn't slash in the indexOn

Upvotes: 0

Related Questions