1

im really new in coding so my question might be very easy. On image below you can see what i have in Firebase.

Here's what i have in my Firebase

In Framer im using this module and after writing this code:

response = (names) ->
    print names

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

im getting something like this:

{-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"}}

the problem is that i want to get only amount. When im trying to change $key to amount it gives me an error:

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

I have a feeling that solution is very simple but i can't find it :(

1 Answers1

0

Fields are not automatically indexed. Since you're trying to filter items by a field amount, you must define an index on that field. Following the documentation on defining indexes, it should look something like:

{
  "rules": {
    "test": {
      "items": {
        ".indexOn": ["amount"]
      }
    }
  }
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • is there a way to get all the items with specific **amount**. For example i need to get all the items where **amount** is 100 ? – Anatoly Sidorov Mar 26 '18 at 07:05
  • right now i have this code `firebase.get("/appMoney/health",response,{orderBy: "type", equalTo: "c"})` and i want it to give me only those items that have **type** equals "c". Is it possible to do? – Anatoly Sidorov Mar 26 '18 at 14:00
  • Yes. Have a look at the [documentation on limit parameters](https://github.com/marckrenn/framer-Firebase#limit-paramters). Something like this should work: `firebase.get("/test/items",response,{orderBy: "$key", equalTo: 100})` (since your value is numeric, you should not use quotes around it). – Frank van Puffelen Mar 26 '18 at 14:24