Save data to a specific user in firebase

Prueba2


Hi, everyone! In advance, I really thank you for your time and patience.
I have created users in firebase from my register screen but now I want to save data (scores) from another screeen for each user. Despite the fact that I have read documentation, search for help in tutorials and dedicated time to solve it for myself, I will be happy if I can get some help from you, thunkers.

2 Likes

First you need to create an app variable to hold the userId in the login / registration screen.
Then in the other screen use this variable to generate the key for the firebase entry.

image

2 Likes

I can’t thank you enough for your diligent help. I did exactly what you told me and it has worked perfectly. Thank you for your support.

3 Likes

prueba1.2


@muneer I am sorry for keeping asking basic questions. These are my blocks but for some reason the scores are overwritten. Do you know what am doing wrong?

Once again, thank you very much for your pricesless help

1 Like

Yes, this is correct.
Under scores you are saving some values. Every time you call the Save block, you are overwriting existing values.

You have two options:

  • Use counters for the scores to avoid overwriting. Example score/1, score/2, score/3 so that every time you increase the number and you will have your scores saved under the number not directly under the score key.

  • Use lists. In the object under scores don’t save the score variable directly but save a list of scores and every time you update the list. When you save, the updated list will be saved.

Let me know if you need more clarification.

1 Like

I am feeling bad for bothering but do you allow me to direct message you, mr. @muneer ?

1 Like

If you feel you want to discuss your project details privately, feel free to send me direct messages.

2 Likes

Hello @muneer, Thank you for such a nice solution - I was also going through the same problem, But can’t get the block of call the database> Please help me with it!

1 Like

You can use cloud variables with Firebase instead of the Readtime DB blocks. There are some examples here: Replace GET or SAVE Blocks with cloud variables.

It’s hard to help someone when they say they have “the same problem” without sharing what they’ve tried. Screenshots or a link to a project are really helpful.

1 Like