vendredi 20 décembre 2019

How to use firebase realtime database as a key value system in reactjs

I am programming a relatively simple web game, the specifics of which are unimportant, except that users accumulate coins by playing. I am using reactjs as the client side and firebase as the backend for authentication and data storage. I have authentication up and running but I am getting stuck when using the realtime database. I have no trouble writing data to the realtime database, but I can't find a good way to read the data back. The data is structured with the parent being "users" under which I have each user identified by user id. Under each user id, there is an integer value called coins. All of the data has already been written, I just need a simple way to read the coins of a specific user given the user id. I have tried data snapshots with no luck. There must be some easy way to access the coin value given a user id as the key. If anyone has any suggestions, I'm all ears.




Aucun commentaire:

Enregistrer un commentaire