In Firebase, is there a way to get the number of children of a node without loading all the node data?
Asked 07 September, 2021
Viewed 2.9K times
  • 57
Votes

You can get the child count via

firebase_node.once('value', function(snapshot) { alert('Count: ' + snapshot.numChildren()); });

But I believe this fetches the entire sub-tree of that node from the server. For huge lists, that seems RAM and latency intensive. Is there a way of getting the count (and/or a list of child names) without fetching the whole thing?

4 Answer