[英]Firebase Realtime Database Dynamic Rules
{
"rules": {
"Users": {
"$user_id": {
// grants write access to the owner of this user account
// whose uid must exactly match the key ($user_id)
".write": "$user_id === auth.uid"
}
}
"BUSINESS NAME HERE": {
".write": "root.child('Users').child(auth.uid).child('BUSINESS NAME HERE').child('Permissions').val() === "MODERATOR""
}
}
}
當用戶訪問業務信息時,他們會在帶有業務名稱的密鑰中訪問所需的子級。 正如上面輸入的,我如何應用它來動態處理他們輸入的任何商戶名稱(很抱歉,如果這對Firebase規則來說是非常基本的新知識)。 謝謝你的幫助!!!
您使用所謂的Dollar變量來標識變量部分:
{
"rules": {
"Users": {
"$user_id": {
// grants write access to the owner of this user account
// whose uid must exactly match the key ($user_id)
".write": "$user_id === auth.uid"
}
}
"$businessName": {
".write": "root.child('Users').child(auth.uid).child($businessName).child('Permissions').val() === 'MODERATOR'"
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.