Firebase and select distinct

前端 未结 2 1141
南笙
南笙 2020-12-22 11:26

My data in firebase looks like

Can I do a select distinct on the Genre node using the REST API of firebase?

2条回答
  •  忘掉有多难
    2020-12-22 11:33

    When you read a tree in Firebase, you get all the children. There's no way around this.

    You can however, create a data structure that holds just the genres per movie.

    {
       "movieGenres": {
          "3646": {
            "0": "Comedy"
          },
          "3647": {
            "0": "Drama"
          },
          "3648": {
            "0": "Horror",
            "1": "Sci-Fi"
          }
       }
    }
    

    Now getting the genres is a simple read.

提交回复
热议问题