I’m working on a small project that involves using the Firebase realtime db. How can I automatically add a child “user id” with its properties (like “nickname”, “picture” and so on…) to the “users” root node (i.e. the cloud var) when the user creates his account?
You would need to use dynamic variables. You can type in the name of the nodes where the “name” section is followed by a / to indicate going inside the node. For example, if you have a user node called “users” and child node named after the “user id”, the way to access the child node would be “users/user id”.
With dynamically creating a child, you would then do “users/” with a join block and the firebase uuid for example.
Can u show me and example, because I have already some something similar to ur suggestion buy it doesnt work.
Ok, thanks.
And how i add child to UserID? and how i set a value to them. Like nickname
There are two ways to do that.
Similar to how I set the cloud variable, you would use a “set cloud variable” block and a “join” block. If you want a child inside the user id, the join block will have “users/”, user id, “/”, then the name of the child.
The second way would be to press the plus button on “create object” to add properties to your object.
And the next question: how can I update the child? for example if I want to change the user’s nickname. I created the object in the second way.
You can either override the entire child or you can use the set property of object block to change one specific property of the child.
This doesn’t seem to work, can you show me an example? We set ownership of a child users object/user ID, but it doesn’t change.
It would be a little difficult to show an example since it all depends on how you have it set up. If you take a screenshot of what you currently have, I can provide some insight into how to modify it to make it work.
The yellow part is obviously a test, the set property does not work correctly, the get property does.
Try using the dynamically named variables block, specifically the set one. Grab the dynamic set variable block and in the name, get a join block with the following: cloud variable users + “/” + app variable user ID + “/nick”. Then the value will be “Text_Input1’s Text”. Give that a try.
Could you send a screenshot of your cloud variables and expand each dropdown option?
I believe that cloud variables users is supposed to be something else, but need to double-check.
I already fixed it, thank u.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.