2016-07-27 89 views
0
{ 
"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規則來說是非常基本的)。謝謝你的幫助!!!Firebase實時數據庫動態規則

回答

0

你用所謂的金錢變量來確定變量部分:

{ 
    "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'" 
     } 
    } 
} 
+0

能否美元變量命名什麼?由於地點而不重要嗎? – XvKnightvX

+0

也即時得到一個錯誤「保存規則錯誤 - 第10行:預期','或'}' 」 – XvKnightvX

+0

我回答了你發佈的單獨問題:http://stackoverflow.com/questions/38604465/error-in -syntax-ON-火力數據庫規則 –

相關問題