首页 > 解决方案 > Retrieving values from Firebase database?

问题描述

Here is my structure of realtime database in firebase

{
    "student1" : {
        "name" : "somename",
        "skillset" : [
            "cpp",
            "c",
            "java"
        ],
        other properties
    },
    "student2" : {
        "name" : "somename",
        "skillset" : [
            "javascript",
            "c",
            "python"
        ],
        other properties
    },
    "student3" : {
        "name" : "somename",
        "skillset" : [
            "cpp",
            "java"
        ],
        other properties
    },
    "student4" : {
        "name" : "somename",
        "skillset" : [
            "java",
            "kotlin"
        ],
        other properties
    } }

I want to retrieve all the students having some specific set of all skills

e.g. skills = ["cpp","java"]
then answer should be ["student1","student3"]

标签: firebasefirebase-realtime-database

解决方案


That is not possible under this structure, as firebase only support filtering by one child. In your case, you would need to get all the data and filter by code


推荐阅读