I want to get all the users that are friends of the logged user. This is my data structure.
{
"users": {
"UID1":{
"name":"Pepito",
"friends":{
"UID2":true,
"UID4":true,
}
}
...
}
}
I am getting the users with this code
Firebase.database.reference().child("users")
.orderByChild("friends/" + Firebase.user.uid).equalTo(true)
And the rules should be
{
"rules": {
"users" : {
".read" : "query.orderByChild.contains('friends/')",
"$uid" : {
".write": "auth.uid == $uid",
}
}
}
}
But the rules not working, I am getting this error when I try to save
Error saving rules – Line 6: Invalid property access: target is not an object.
The line 6 is
".read" : "query.orderByChild.contains('friends/')",
I also tried with
".read" : "query.orderByChild == 'friends/'+auth.uid",