如何从firebase实时数据库中选择数据

时间:2022-08-21 13:22:19

I have a database with a structure, roughly like

我有一个结构的数据库,大致相似

// An index to track Ada's memberships
{
  "users": {
    "alovelace": {
      "name": "Ada Lovelace",
      // Index Ada's groups in her profile
      "groups": {
         // the value here doesn't matter, just that the key exists
         "techpioneers": true,
         "womentechmakers": true
      }
    },
    ...
  },
  "groups": {
    "techpioneers": {
      "name": "Historical Tech Pioneers",
      "members": {
        "alovelace": true,
        "ghopper": true,
        "eclarke": true
      }
    },
    ...
  }
}

But I can't figure out how to select users who are members of the same set of groups

但我无法弄清楚如何选择属于同一组组的用户

1 个解决方案

#1


0  

You'd have to define an additional group_combinations or all_groups index, where you store each user under their combines the groups:

您必须定义一个额外的group_combinations或all_groups索引,您可以将每个用户存储在它们组合的组中:

all_groups: {
  "techpioneers_womentechmakers": {
    alovelace: true
  }
}

#1


0  

You'd have to define an additional group_combinations or all_groups index, where you store each user under their combines the groups:

您必须定义一个额外的group_combinations或all_groups索引,您可以将每个用户存储在它们组合的组中:

all_groups: {
  "techpioneers_womentechmakers": {
    alovelace: true
  }
}