我想让所有用户都是已登录用户的朋友。这是我的数据结构。
{
"users": {
"UID1":{
"name":"Pepito",
"friends":{
"UID2":true,
"UID4":true,
}
}
...
}
}
我正在通过此代码获取用户
Firebase.database.reference().child("users")
.orderByChild("friends/" + Firebase.user.uid).equalTo(true)
规则应该是
{
"rules": {
"users" : {
".read" : "query.orderByChild.contains('friends/')",
"$uid" : {
".write": "auth.uid == $uid",
}
}
}
}
但规则不起作用,我在尝试保存时收到此错误
Error saving rules – Line 6: Invalid property access: target is not an object.
第6行是
".read" : "query.orderByChild.contains('friends/')",
我也试过
".read" : "query.orderByChild == 'friends/'+auth.uid",