【发布时间】:2019-01-24 22:40:38
【问题描述】:
我想让只有用户能够创建新帖子,并且只有用户才能修改他们创建的帖子。喜欢删除或编辑!
数据库结构
{
"post" : {
"-LWzHsKzAyK9Wfa1kbD_" : {
"name" : "test",
"title" : "test",
"userId" : "8D3sENaBcLaXoGNnh1MPuoyj5LP2"
},
"-LWzHx6u-gQ7XoVR714a" : {
"name" : "check",
"title" : "check",
"userId" : "WUM2HBkGo8TFDeOjEqO1s3lCj1p1"
}
}
}
我使用了这个规则,但是我在保存No such method/property 'userId'.时出错
{
"rules": {
".read": false,
".write": false,
"report": {
".read": "auth != null",
".write": "auth != null && ( (data.exists() && data.userId === auth.uid) || !data.exists() || !newData.exists() )"
}
}
}
【问题讨论】:
标签: firebase firebase-realtime-database firebase-security