0

I want to 'get' just the first tier information from my firebase JSON via the REST api, without any of the nested arrays each object has. How can I do that with firebase, to avoid having to download the entire dataset?

i.e. from the JSON below I just want to return:

{ "people":[
   {"name":"bob"},
   {"name":"dave"}
   ]}

Full data

{  
   "people":[  
      {  
         "name":"bob",
         "measurements":[  
            {  
               "measname":"first test",
               "weights":[  
                  {  
                     "device":"scaleA",
                     "weight":78.0
                  },
                  {  
                     "device":"scaleA",
                     "weight":78.2
                  }
               ]
            }
         ]
      },
      {  
         "name":"bob",
         "measurements":[  
            {  
               "measname":"first test",
               "weights":[  
                  {  
                     "device":"scaleA",
                     "weight":78.0
                  },
                  {  
                     "device":"scaleA",
                     "weight":78.2
                  }
               ]
            }
         ]
      }
   ]
}
Ian
  • 1,427
  • 1
  • 15
  • 27
  • Did you try anything yet? If so, please share the code. It helps prevent people from coming up with a solution that is not what you're looking for. – Frank van Puffelen Jul 27 '15 at 04:34
  • I've not found anything yet in the [firebase REST docs](https://www.firebase.com/docs/rest/api/) that indicates you can do GETs with this kind of functionality. (I thought that the 'shallow' param might be what I was looking for, but it just returns true or false for each key.. puzzling) – Ian Jul 27 '15 at 04:36

1 Answers1

1

Edit: I didn't realize you specified this needed to be server-side. According to this question, it doesn't seem to be possible: Database-style Queries with Firebase

Community
  • 1
  • 1
jmar777
  • 38,796
  • 11
  • 66
  • 64
  • Not quite what I was after. I need this refinement to happen before downloading the data. I'm trying to avoid large data downloads. – Ian Jul 27 '15 at 04:34
  • jmar777 posted a response (which he's since deleted) linking to this which sheds some light on the issue http://stackoverflow.com/questions/11587775/database-style-queries-with-firebase – Ian Jul 27 '15 at 04:46
  • Yeah, I initially thought your question was ambiguous, and then I retracted my comment after re-reading it. :) The link is embedded in the updated answer now. Thanks for the accept. – jmar777 Jul 27 '15 at 14:06
  • Further, this guide has also persuaded me to restructure my data to be flatter https://www.firebase.com/docs/web/guide/structuring-data.html – Ian Jul 27 '15 at 14:36