更新这样的规则后,我无法在 React Native 应用程序中访问 firebase 数据库
{
"rules": {
"main_data":{
"$uid": {
"xx1":{
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
},
"xx2":{
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
}
},
},
}
}
我有像
这样的json结构main_data:{
{"uid":{
"xx1":{"id":"uid","d2":"val2","d3":"val3","d4":"d4","d5":"val5","d6":"val6"}
},
"xx2":"value"}
}
我在 react native app 中遇到了这个错误
@firebase/database: FIREBASE WARNING: update at /main_data/UID failed: permission_denied
我通过以下代码访问它
firebase.database().ref('main_data').child(UID).child("xx1 or xx2")
.on("value", data=>{
console.log(data)
})
更新 : 忘记分享写代码了
firebase.database().ref('main_data/' + UID).update({
xx2: "Some_value",
}).then(() => {
console.log("Success!!")
}).catch((e) => {
console.log(e)
})
答案 0 :(得分:0)
我浪费时间解决了,,,实际上是我在我的项目中使用的包不匹配问题