Hi
I am trying to save my items to Firebase through Cloud variable but also for a specific user.
I have created a sign in page with a sign in component and I have put the logged in user to a variable just to make it easy to use later in the app.
Now I would like to add my items inside of that user somehow. I know how to do this in the Real time database component but I am trying out the cloud variables now and I feel I would need some help.
Anyone with any tips for me? Thanks!
This is my database today:
I would like it to end up more like this:
This is my “save” block where I tell how the info should be saved in database:
I’m not sure of what you are trying to say but if you want to store the list under the user ID then you need to create a cloud variable to point to that node
See an example of my project
Each student using my app has a unique user ID and all the student info is saved under this user ID.
This will save the list under a bucket called “myProject” under the user ID specified.
Ok great, thanks. Yeas that’s kind of what I am looking for. May I ask, is “set cloud variable…” (the block you have used) kind of the same thing as using the block “initialize cloud variable block” (which is what I have done) ?
What would be the difference really? I have been looking at this block already but couldn’t really understand it and why…
When do I use the “initialise block”, and when do I use the “set-block”?
The variable that are created by the Initialize block are fixed variables and the name of the variable cannot be changed. When accessing Firebase RTDB using the cloud variables you will often need to change the node structure dynamically and for this you use the other type of variables.
and here it looks like they have “named” these cloud variables. When I try I only get this dropdown with types, I can only see how I can name these if I do a fixed (initialised) variable…?
what I would like to do is to do do as in this guide,
when SAVE the list, use the “cloud” variable and make text from the “local” variable,
And
when GET the list, use the “local” variable and make list from the “cloud” variable.
I get this to work when using fixed (initialised) variables, but as I am not able to name the “set”-variables I don’t get how to pick up the cloud-variable in the GET method…??
The unnamed variables are actually keys in Firebase so you will always refer to the key as the name of the variable.
For example, if I want to check the last time the student logged in I will use the unnamed variables to access the data this way
I’m not using variables but actually constructing the Firebase node to retrieve data.
May I ask, I believe I got everything to work as I want now. But I notice that when start the app, and the items are syncing with the database, the process are really slow, its probably cause of how I have wrote it. But would you have any tips to me how I could set it up to be more fast in its sync-process?
I have chosen to, when start the app, delete all rows from my DVL and then get the data from the database and create new rows for every item of that data into my DVL-list. And yea, I’ve put all this in a function and call on in my “open screen-block”. This seam to be a bit lagging and probably I could do this some other way?
This is my block for the function that runs when opening the app:
And here you can see a small video showing what I’m talking about. Its clearly lagging when startup the app. But nothing is missing and everything works how I like…
This could actually be a really great idea, I have set up something like that now, but I notice that there is still a DVL showing -before- the screens “open or start”-block runs. It is something like “the last view list” or so, not synced… That is shown for like a half. second or so…
How can I hide that also? Any ideas?
I did something so simple as this now, and it works fine, except for that “dead” list in the very beginning…
Sorry guys, I am not sure if I do wrong in adding this question here, but I am really happy with the app now, and I am trying to provoke it just to make sure nothing weird is happening. Then when I tried to login with a new user I started with an empty list as suspected. But then as soon as I entered a new item the items from the previous user showed, an the new item I added was added to that other users list.
But then I tried to login with a third user, and that went fine all the way. Nothing weird happened, it started with an empty list and as I added new things it was only these that was shown.
Then I logged back to the other user which acted weird and removed all the items from it and started over and now that user acts as suspected as well.
I am wondering, is there anything I could add to the code to prevent these kind of things to happen?
I guess it should be the “save” block which may missing something, as the old users list appeared only after added a new item?