Firebase规则的通配符

时间:2017-10-13 21:01:43

标签: firebase firebase-realtime-database firebase-authentication firebase-security

我有一个与IMDB ID一起使用的数据库,并且在它们下面有一些类别。我想给任何用户,无论是否具有身份验证权限,都可以创建这些类别,并修改其中一些内容,但不修改其他内容。我可以用什么样的通配符代替任何IMDB ID

看起来大致像这样

"Movies"
|
|
|_______$IMDB_ID   //Should be read/writeable by anyone
               |
               |
               |
               __________Detail 1  //read/writeable by anyone
               |                 |
               |                 |___Detail Name  //read-writeable by anyone
               |                 |
               |                 |___Detail Score //readable by anyone, writeable with authentication
               |                 |
               |                 |____Detail Tally //readable by anyone, writeable with authentication
               |
               ____________Detail 2
                           |
                           |____Detail Name
                           |
                           |____Detail Score
                           |
                           |____Detail Tally

1 个答案:

答案 0 :(得分:0)

看起来你要求这个:

{
  "rules": {
    "Movies": {
      ".read": true,
      "$IMDB_ID": {
        "$DetailId": {
          "Detail_Name": { ".write": true },
          "Detail_Score": { ".write": "auth !== null" }
          "Detail_Tally": { ".write": "auth !== null" }
        }
      }
    }
  }
}