I'm trying to increase performance in my Firebase Realtime database by creating indices by following recommendations in the console log. Most recommendations are easy to follow, but not all.
My existing rule:
"notes": {
".indexOn": ["data/title", "access/author"],
".read": "
auth.uid !== null
",
"$note_id": {
".write": "
(!data.exists() && auth.uid !== null) ||
(
data.child('access').child('author').val() === auth.uid
||
data.child('access/members').child(auth.uid).exists()
)
",
"data": {
".read": "
data.parent().child('access').child('author').val() === auth.uid ||
data.parent().child('access/members').child(auth.uid).exists()
",
".write": "
data.parent().child('access').child('author').val() === auth.uid ||
data.parent().child('access/members').child(auth.uid).exists()
",
"access" : {
".read" : "
(auth.uid !== null) &&
(
data.child('author').val() === auth.uid
||
data.child('members').child(auth.uid).exists()
)
",
"members" :{
".write" : "
(!data.exists() && auth.uid !== null) ||
data.parent().child('author').val() === auth.uid ||
data.parent().child(auth.uid).exists()
"
}
}
}
},
Some recommendations are for locations that end with the users uid
- similar to the below console log:
FIREBASE WARNING: Using an unspecified index.
Consider adding ".indexOn": "access/members/3weT1tYhG456HH0CuC45Muc44ax6" at /notes to your security rules for better performance
Can this index rule be added in Firebase Realtime Database - considering the location locations is ending with user uid
string?