不能有多个默认规则

Can not have multiple default rules

我正在使用 GeoFire 在 Firebase 实时数据库中存储位置。我有 2 tables table-atable-b。对于这两个 table,我想启用索引。保存以下规则时,Firebase 会提示以下错误:

不能有多个默认规则(“$table-a”和“$table-b”)。

    {
      "rules": {
          ".read": "auth != null",
          ".write": "auth != null",
          "$table-a": {
          ".indexOn":"g"
            },
          "$table-b": {
          ".indexOn":"g"
            }
      }
    }

关于我在这里可能遗漏的内容有什么想法吗?

我认为你应该做如下:

{
  "rules": {
      ".read": "auth != null",
      ".write": "auth != null",
      "table-a": {
      ".indexOn":"g"
        },
      "table-b": {
      ".indexOn":"g"
        }
  }
}

here 所述,$location 语法为 "used to reference the key of a $location that was used earlier in a rule structure"