0

I am trying to learn how to make rest calls with firebase

I have the following but get no results,

('/cases.json?orderBy="case_status"&equalTo="live"')

if I remove the

?orderBy="case_status"&equalTo="live"' 

I get all my results returned

('/cases.json?orderBy="$key"&limitToFirst=2')

also works

my firebase table is as follows

cases
 -LFXvk9yY5c-O8yIdf8k
   case_name: "Issue 1"
   case_status: "live"
   case_summary: "Problem with code"
   contact: "Fred"

-LFXvk9yY5c-O8h45std
   case_name: "Issue 2"
   case_status: "complete"
   case_summary: "Also problem with code"
   contact: "Fred"

I also tried adding a rule as below but that didn't work either

{
  "rules": {
    ".read": true,
    ".write": true,
    ".indexOn": "case_status"
  }
}

Can anyone tell me why the filter doesn't work as from the docs looks like it should

Thanks

1 Answer 1

1

You have probably missed the following warning in the REST API documentation at https://firebase.google.com/docs/database/rest/retrieve-data

Add Indexing to your Firebase Realtime Database Rules: If you're using orderBy in your app, you need to define the keys you will be indexing on via the .indexOn rule in your Firebase Realtime Database Rules.

Your rules should look like:

{
  "rules": {
      ".read": "true",   //just an example, probably to adapt!!
      ".write": "true",  //just an example, probably to adapt!!
      "cases": {
          ".indexOn": "case_status"
       }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.