Get properties of object stored as a cloud variable list

I’m defining a cloud variable like this:

which produces a db structure like this:

On another screen, I want to query the list stored in the ‘round’ object, and display what is stored under the ‘p1d’ field. UserID+date should give me a unique key for each entry in the list, but I can’t figure out the combination of blocks to make the query work.

Help please!!

1 Like

Can you explain further.
round is your top key. Under this key is a numbered list (0,1,2,…) Each element in this list is not a simple text element but an object comprising number of element.

What exactly you want from this structure to be displayed in your screen?

I want to be able to store, retrieve, and update individual rounds. Many users will be able to start rounds, then take some action in the physical world, and record their results in the app. So I need to be able to:
A) find, display, and update properties of a user’s most recent round (to record results)
B) find and display all the rounds from a particular user (to show history)

I’ve never worked with an object-oriented DB structure before, so I’m basically thinking of each item under the “round” object (0,1,2,…) as a row in a relational DB table. I’m not sure if this approach is optimal, so I’m def. open to any other feedback if there’s a better way to accomplish this. :slight_smile:

I thought of storing the entry of the numbered list (0,1,2,…) in an app variable when each round is created, but I can’t figure out how to get that value. I could query for the last item in the list, but that’s prone to failure if two users create rounds at the same time.

1 Like

I’ll try to replicate what you have and produce an example project. It would be easier to then explain based on a working app.

Please see the sample project.
https://x.thunkable.com/projectPage/605af190400c170013e66b78

You need to supply the API Key and Database URL in the project properties page and just press the button to get the data stored in your database in a list viewer.

When you select an item from the list viewer, more details are shown in two labels.

Let me know what you are trying to achieve so we can progress further.

Thanks for taking the time to create this!

I realize that I’m storing these objects as a list, and so that might require me to use a list viewer, but if possible, I would like to find a way to display parameters of individual rounds (and update them) without the user needing to deal with the list. They won’t know which number (0,1,2,…) is relevant - I’d like that to be “behind the scenes.”

Should I use some other method of storing the data?

1 Like

Of course you can have the (0,1,2,…) In the back scene but you need to first select one of the keys (or a combination of two keys) as a primary key to show it to the user in the list viewer.

Let me know which of your data is the main key you want it listed and when the user selects it then you will show the rest of the data and maybe allow the user to change some of the contents.

I can redesign the project easily.

Here’s a quick wireframe of what I’m trying to achieve:

I believe that for this to work, I need to be able to get to the specific object in the “round” list that was created [when [buttonRound] [Click]] in my code screenshot, above. I think that ‘userID’ + ‘date’ should give me a unique key to any individual round.

1 Like

The userID you showed was empty but I can get the date, userID combination.

So, is it each user goes through the round or any user can pick whatever in the database and start using it?

If your App is user specific then you might want to consider restructuring your data so that:

round
----userID1
--------date1
--------p1d
--------p1s
--------p2d
--------p2s

--------date2
--------p1d
--------p1s
--------p2d
--------p2s

----userID2
--------date1
--------p1d
--------p1s
--------p2d
--------p2s

--------date2
--------p1d
--------p1s
--------p2d
--------p2s

Which should result in easier access to the data.

The app should be user-specific. Users will get a userID from the thunkable/firebase ‘Sign In’ component.

I like your plan for the structure, but I don’t know how to create that setup. The list block I’m using just creates the (0,1,2,…) by default. How can I define the object to have a userID in the place of that (0,1,2,…)?

1 Like

I made some changes to my project to display a more meaningful info in the list viewer. Please remix the project to see the updates. I inserted some names in the database to make the list proper.

image