我试图在我的firebase数据库上实现我的数据库规则。
现在我有:
{
"rules": {
".read": false,
".write": false,
"users": {
".read": true,
".write": "(auth != null) && !root.child('users/'+ newData.child('slug').val()).exists()",
"$username": {
".read": false,
".write": false,
"clubs": {
".read": "(auth != null)",
".write": false
},
"roles": {
".read": "(auth != null)",
".write": false
}
}
},
"clubs": {
".read": true,
".write": true
}
}
}
,数据如下:
{
clubs: {
smash_for_fun: {
description: "The best club ever!",
name: "Smash For Fun",
slug: "smash_for_fun",
users: {
glenn_lastname: true
}
}
},
users: {
glenn_lastname: {
clubs: {
smash_for_fun: true
},
name: "Glenn Lastname",
slug: "glenn_lastname",
uid: "edtJDkUnEOXAUnl0J9GfXIsOqgG2"
},
other_user: {
name: "Other user",
slug: "other_user",
uid: "sgsdkjfnsdfnsdkjfnlsdfndsjfn"
}
}
}
但我如何制定规则,以便用户只能编写自己的详细信息,而不是来自其他用户呢?
以及如何检查user.slug是否不存在?