0

I found solutions for this problem only with snapshot, which downloads the whole database. It would be great to send a request to Firebase server which would respond the total number of records. Downloading the whole database is not really efficient. Any idea?

Related questions. (Most suggest watching value event, and checking size of the downloaded records... not efficient.)

Firebase better way of getting total number of records

Total number of records in Firebase (when am I done counting?)

Firebase - Count online users

Community
  • 1
  • 1
Zoltan
  • 4,936
  • 1
  • 35
  • 40
  • 2
    There is one more recent [post on this](http://grokbase.com/t/gg/firebase-talk/14ajy2t3nt/firebase-child-count-with-good-performance), looks like they only provide API to download object keys instead of all objects. But there is no true server-side count – Kirill Slatin Jul 13 '15 at 02:45

1 Answers1

1

You can try ?shallow=true in GET request to retrieve total set of keys. Still downloading all the keys but limit the depth, hence much faster than watching value.

Docs on shallow parameter

ilia onic
  • 21
  • 5
  • Thanks. This is one of the partial solution... but it could be still huge payload for a simple number... let say, you have a 50.000 records in a table... already a quite big... Probably while Firebase doesn't implement this feature, Firebase is a little bit limited... – Zoltan Jul 16 '15 at 05:22
  • 1
    Hope this helps - http://stackoverflow.com/questions/15148803/in-firebase-is-there-a-way-to-get-the-number-of-children-of-a-node-without-load/23132570#23132570 – ilia onic Sep 07 '15 at 23:56