Whenever I am trying to query some data in order to delete a folder in Realtime Database, I get the following warning:
Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "id" at /comments/evChargers/D6A3D94D-1F2F-467B-A6C5-F6D9BF7D1C02/AKsxbJAifSbsIhFONMSFT6UTarS2 to your security rules for better performance
However, the values D6A3D94D-1F2F-467B-A6C5-F6D9BF7D1C02 and AKsxbJAifSbsIhFONMSFT6UTarS2 are not constant and will change based on some variables in my app. Obviously, the folder names on my Realtime Database have those variables names.
Is there any way to add dynamic rules in Realtime Database? Thanks in advance!
>Solution :
You can add indexes (and security rules) at a dynamic path by using wildcard capture variable to define it.
So yours could be something like:
{
"rules": {
"comments": {
"evChargers": {
"$id1": {
"$id2": {
".indexOn": "id"
}
}
}
}
}
}