如何为firebase中的嵌套值编写.indexOn?

时间:2017-04-15 12:18:29

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

enter image description here

我已经写了下面的规则来获取带有密钥created的值格式聊天但是我无法从Firebase DB获取值。规则在下面

"chats": {
  ".read" : true,
  ".write" : "auth !== null",
      "messages" : {
            ".indexOn": ["userName", "createdAt", "userId"]
        }
},

聊天/ messages.json ORDERBY = “createdAt” &安培; startAt = 1485920224250&安培;打印=相当

1 个答案:

答案 0 :(得分:2)

您在规则中错过了一个级别:

"chats": {
  ".read" : true,
  ".write" : "auth !== null",
  "$chatId": {
      "messages" : {
            ".indexOn": ["userName", "createdAt", "userId"]
        }
  }
},