What is the best way to search data in Firebase?

Sorry, I couldn’t make a better title. Anyway, I will explain better below:
I made an app for a client, and now he is asking me to create one way for him to see and edit users data like email, adress, etc.
This is no problem, but to do this I have to find the account of the user. The path used in firebase is: users/idoftheuser/data:value. The problem is, the id of the user is a random combination of numbers and letters (the same id of firebase authentication), so I can’t get the user data using “firebase get tag userid”.

To find the user I would have to search for email or name. But this app has about 10k users, so I would have to check the name or email in each one of them until I find it. This could be a little slow and would cost much since this app already uses more than the free firebase (plan spark) offer. something simple like searching 10 users could mean up to 100 thousands of readings in Firebase Real Time DB.
My question is: Is there a better way to do this search? Any way that allows me to search for an email, for example, without having to check the entire users database?

As Much as I Read and Understood
You want to Get Details of the Users in the App from Unique UserId given by Firebase Auth.

Please Share the Structure of db just an example.

Also to do this Make a Seperate App or Feature in that Particular app where a Particular person can see others Details in form of a Profile page like instagram or Other Social Media. I am saying this Because you said Each person’s Information is Stored in Seperate Bucket Assigned to him/her. So Set your Bucket as the Whole of your Firebase to Get Tags Called E-Mail and make a list of the Values

This is the structure:
image
Only the admin of the app will have to make this search by email or name.

It is not a problem for me to search by email. The problem is that this will cost more money and time since I will have to get each /usuarios/randomid/email tag and see if the email is the one I am looking for

I don’t think there is any reasonable way other than to create an index of all the emails and userIDs associated with them…

you can create a program to do it for you if the user base is already a large number it could use a lot of data but it’s a one time thing and then you just set the bucket to user’s email and get their ID

2 Likes

Good idea, I will create a list or dictionary with emails and IDs. Then I get the id and make a get tag id.
Thanks​:hugs:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.