Firebase 规则:什么是 .contains()?

Firebase Rules: What is .contains()?

我已经通读了 Firebase Documentation 但不明白什么是 .contains()

以下是文档中 Firebase 数据库的示例规则:

{
  "rules": {
    "rooms": {
      "$room_id": {
        "topic": {
          // the room's topic can be changed if the room id has "public" in it
          ".write": "$room_id.contains('public')"
        }
      }
    }
  }
}

请问这是什么$room_id.contains('public')

是指$room_id的child吗?

$room_id 是作为 "topic" 的父项出现的匹配的通配符键名称。该规则仅在该键名称中的任何位置包含字符串 "public" 时才允许写入。

因此,如果有人试图将 /rooms/public_roomid/topic 的值更改为某个值,那将是允许的。但是,写入 /rooms/roomid/topic 将被拒绝。