Christin Brown
Christin Brown

Reputation: 33

Firebase read/ save Data to use it as a list | Swift/Firebase

Hello I have The Following Problem, I want to save my data to my realtime Database so, that I can use it as a list.

Now It is like this

so know I am trying to save the PartyId (yellow) with a uuid (red), but this is not really working, because I need the uuid to use it on swift.

So are there probably any other ways to save or read the data.

Thanks in advance.

Upvotes: 0

Views: 377

Answers (1)

scobr
scobr

Reputation: 166

If you only need to store the data in an array, you need to add the index of the element as a key, and the PartyId as the value.

database structure

This make the "Array" element to be able to be treated as an array when you retrieve the data.

Just to be mentioned, if you need to make some queries when you retrieve the data (for example, how many users assist to a specific party) consider to flatten your structure data like this:

flat database structure

With this you can be able to query, for example, all the users that have a specific partyId. For more information, you can check the documentation to create good data structures

Upvotes: 1

Related Questions