0

Is there any way in year 2020 to get the number of children of a node in Firebase Database without downloading the entire payload on the client? I have about 20 000 users in db and I want to get a count of them.

Users
   userUID_1
       - 300 properties
   userUID_2
        - 700 properties
     .
     .
     .
bibscy
  • 2,598
  • 4
  • 34
  • 82

2 Answers2

1

I will give you a better idea:

create a new node called UsersCount:

UsersCount
|
|--------------number : "..."

When you save users to Users at the same time update the number in the UsersCount, now when you want to get the users count you don't have to read the whole Users node, instead you just read the UsersCount

Hasan Bou Taam
  • 4,017
  • 2
  • 12
  • 22
0

I guess that you could implement a function to retrive this count within the server.

Juanje
  • 1,235
  • 2
  • 11
  • 28
  • Can you elaborate. There is no count for users in the db. I don't want to download all the users every time I need the count of users. There are already thousands of users in the database. – bibscy Apr 28 '20 at 14:41