Ionic and Firebase - Images Upload Limit

Hello,

This is my first time developing an application so this question can be quite obvious for the most but for me i am still struggling.

In my app you can upload pictures for a item to firebase, everything is working fine but i would like to set a limit to the number of pictures that can be uploaded.

How can I set the intelligence to send a request to firebase and check if there are already 4 pictures on my database therefore i can disable the button to upload more?

Thanks in advance.

found solution here -> https://stackoverflow.com/questions/42352761/counting-items-with-firebaseobservable-in-angular-2