1

I would like to retrieve children on a specific node on my Firebase database. However I don't want to pull down all of them, I'm only interested in a specific set for which I have the keys. I know I can accomplish this by just retrieving all of the children and check for their KEYs when they come back, but I expect this particular node children to grow quite large, and doing this would be extremely inefficient.

I could also explicitly aim each children like this:

firebase.child(PARENT_NODE).child("objectId1").addValueEventListener(this);
firebase.child(PARENT_NODE).child("objectId2").addValueEventListener(this);
firebase.child(PARENT_NODE).child("objectId3").addValueEventListener(this);

But this doesnt feel "right", somehow. I would have to unsubscribe from three or more connections, I can see this getting messy quickly. Is there a way to do something like:

firebase.child(PARENT_NODE).children(new String[] {"objectId1", "objectId2", "objectId3"}).addValueEventListener(this);

Thanks

Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
frankelot
  • 12,349
  • 15
  • 47
  • 84
  • firebase.child(PARENT_NODE).orderByKey().startAt(YOUR_START).endAt(YOUR_END).addValueEventListener(this); – Dhruv Apr 21 '16 at 13:12
  • Unfortunately, my keys dont follow any specific order – frankelot Apr 21 '16 at 13:16
  • Loading multiple items in Firebase is a lot faster than you may expect. See http://stackoverflow.com/questions/35931526/speed-up-fetching-posts-for-my-social-network-app-by-using-query-instead-of-obse/35932786#35932786 – Frank van Puffelen Apr 21 '16 at 14:27

0 Answers0