我正在尝试使新的帖子对象只能由每个帖子中存储的“成员”字典中存在的用户读取。我不断收到“7:17:无效 == 表达式:左操作数不是数字、 bool 值、字符串或 null。”关于 .read 规则:
{
"rules": {
"posts" : {
".write":true,
"$post" : {
".read": "data.child('members').child(auth.uid) == true"
}
}
}
}
我在生成的 token 中传递了“uid”参数:https://www.firebase.com/docs/security/custom-login.html
目的是只允许其成员数组中存在的用户读取帖子。我在 firebase 文档、Google 群组或 Google 搜索中找不到任何有关访问嵌套数据的示例:-(
这是允许/可能的吗?
最佳答案
您需要在 .child() 之后添加 .val() 才能获取值。 :-) 尝试一下:
".read": "data.child('members').child(auth.uid).val() == true"
关于firebase - 通过经过身份验证的用户访问条件嵌套数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15059030/