1

I wanna pull whole data from the firebase database and access that without change data.

firebase.database().ref(‘someBigNode’).once(‘value’, (snapshot) => {
    //do something
}

But it will cost many memory.

May I ask how to pull whole data partially and save memory?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

4

When you read data from Firebase Database with the JavaScript (or iOS or Android) SDK, it will always read complete nodes. So the only way to retrieve less data is to retrieve a node lower in the JSON tree.

If you find you need to retrieve a part of each node under someBigNode, you should split that part of each node out into a top-level node of their own importantBitsOfSomeBigNode.

It's unfortunately hard to be more helpful without a more concrete example of your data structure and the bits you're trying to retrieve (and the reason why those bits are special).

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I try to use startAt, endAt or limitFirst to do that in a loop, but it make me feel pain :( – programer5566 Feb 17 '17 at 03:35
  • 1
    Sorry, that's a rather unactionable statement. If you still have a question, please update your question with the code *and* the data that you're querying. Otherwise, we're taking blind guesses beyond explaining how Firebase works - as I did above. – Frank van Puffelen Feb 17 '17 at 04:59