I have created a Firebase structure like this and would appreciate it if you could help me with the correct blocks to get the properties of a list within a list. I have managed to create the database from Thunkable, but I struggle to get values/properties from nested lists. I do not use the Real time component, but rather the Cloud Variables as recommended. - Thank you in advance.!
Cloud Variable Help|497x500
Hey! @dmndeklerkeb, welcome to the community and thanks for posting!
Can you try something like this?
You could try remixing this app to see something similar in action
Thank you for your help with this. I will give it a go later and will let you know. I understand what you have done here. Thanks again. I have remixed the NedtdList and will also look through that. Will keep you posted.
I have tried the way you suggested but it does not fetch the property. I also tried the way in your NestdList. Bear in mind I do not use a listview component. I would like to fetch a value based on a stored user ID and then would like to do some validation. If the user is not in the list, I would like to add the new user to the list of users of that specific group. The whole idea is to check if the stored user is in the list or not and if so, to avoid saving the user ID as a duplicate in the list.
I hope this clarify more of what I am struggling with. Thanks for you advice in advance.
Hey there @dmndeklerkeb
What about something like this?
Hi, thank you so much. I will have a look and revert.
I have exactly set it up like in your example. I would like to trigger the function with a button. What do I use then as an input to the function? And, should I leave open the GROUP and TOKEN fields?
The inputs needed would be for Group and Token. to do that, i would create function variables named _group and _token.
All other needed arguments should be self contained already. You will need to have already assigned a value to userID. this should be accomplished with the RealtimeDB login blocks.
Please check, this is my version. Unfortunately I don’t get it to work. Am I doing something wrong?
first, see what the length of this is
I’m wondering, was cloudvariable set as a list anywhere in the app already or did you give it a predefined data structure?
The length is 3 for now. The cloud variable was set to an empty list before I used it to create the 3 records. See below.
which part isnt working? ensuring no duplicates are made?
perfect! next step, see if after running that loop does _addDontAdd equal anything?
I also have another idea
let me put it together
how about this as the loop.
this may work.
plus the other blocks. but a loop instead of a Count By block
_addDontAdd returns ‘undefined’
If you set it to 0, and only perform math operations with it then it should still return a value.
I also caught an error in my code. you dont want to add to list _addDontAdd, this value is just to let the app know wehter or not to add another user. You would want to add to the list of GROUPS
I have seen it also that _addDontAdd was not initialized as a list. I will try agin.
not necessary. you aren’t making that value a list ever according to my code.
it should only be used to count if there were matches between the input and the currently existing data.
the first logic here makes sense, but when you get to ‘in list’ you want to add to list ‘GROUPS’. you are not adding into list _addDontAdd because 1) it’s not a list type variable 2) it’s not your user list
lemme know if you get it working!
Ok, so I got three new entries in the database, which look like this: #3 - #5. It added similar entries and the check for duplicates did not work.
Sorry I have run out of posts on my first day. It says I have to wait 17 hours. So I will add to this. I had a wrong Group name variable assigned. Rectified that and now it creates 6 new records of the same.
Yes it will. I have seen in the code with the first If statement testing for same User ID and then it goes and add the records in the second If statement. What I did is, I have changed the = to /= and now if I run it, it does not add, but it also does not give me the error message. So I think a little bit of tweaking will get it to work. How do I share my private project?
How can I add to the list of user ID’s within the user list of one group. Instead it saves an additional record. Is this how it suppose to work with firebase?
Ah, ok. That will work for me, however, I will have to experience with that first and see if I can do that. Alternatively, if it is not too much to ask you could I ask you to help me to what i should do. I am still new in this and would really appreciate.
so it added 3 new entries. then it added 6 entries?
I’m guessing if you ran it again, it would add 12 entries?
can you share your code?
To add to the users of a single user group, you can get and remove that object from the overall list of uers groups, append an item to that individual object, and then replace the object in the overal list.