While going down in the firebase's structure data page, there is an example of users<->groups relationship. It is a nice way to store data that contains two-way-relationship.
Here is the relation explained on that page:
// 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
}
},
...
}
}
By storing data that way, how can I query that data to show the list of groups of a particular user?
How can I query that data? equalTo()
can not do that as it takes only one key.