在 Framer 中从 Firebase 获取特定密钥

Getting specific key from Firebase in Framer

我真的是编程新手,所以我的问题可能很简单。 在下图中,您可以看到我在 Firebase 中拥有的内容。

Here's what i have in my Firebase

我在 Framer 中使用 this module 并在编写此代码后:

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:{amount:37863, date:"25.3.2018", type:"b"}}

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

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

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

字段不会自动编入索引。由于您正尝试按字段 amount 过滤 items,因此您必须在该字段上定义一个索引。在 documentation on defining indexes 之后,它应该类似于:

{
  "rules": {
    "test": {
      "items": {
        ".indexOn": ["amount"]
      }
    }
  }
}