I have the follow data structure in Firebase Realtime Database.
{
groups: {
$groupid: {
$userid: Boolean
}
}
}
Here #groupid
and $userid
vary.
When a user with id "user0" is in the group "group0", it will be
{
groups: {
...
group0: {
user0: true
}
...
}
}
When the user is removed, it will be user0: false
.
When I query groups with a specific user, Firebase SDK
shows a warning:
FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "user0" at /groups to your security rules for better performance
As the user id varies, I think all user ids should be indexed on.
How can I write a relevant security rule?