1

我在编码方面真的很新,所以我的问题可能很简单。在下图中,您可以看到我在 Firebase 中的内容。

这是我的 Firebase 中的内容

在 Framer 中使用此模块并编写此代码后:

response = (names) ->
    print names

firebase.get("/test/items",response,{orderBy: "$key"})

我得到这样的东西:

{-L8S1RLTU3P3Lb-PxtsF:{amount:24926, date:"25.3.2018", type:"c"}, -L8S1RTNNySP0quUICNt:{amount:23616, date:"25.3.2018", type:"c"}, - L8S1RYPmG8L_EkYV8Vd:{金额:37863,日期:“25.3.2018”,类型:“b”}}

问题是我只想得到数量。当我试图将$key更改为金额时,它给了我一个错误:

{error:"Index not defined, add ".indexOn": "amount", for path "/test/items", to the rules"}

我觉得解决方案很简单,但我找不到:(

4

1 回答 1

0

字段不会自动索引。由于您尝试items按字段进行过滤amount,因此您必须在该字段上定义一个索引。按照关于定义索引的文档,它应该类似于:

{
  "rules": {
    "test": {
      "items": {
        ".indexOn": ["amount"]
      }
    }
  }
}
于 2018-03-26T00:33:39.767 回答