# Firebase data storing

**URL:** <https://community.thunkable.com/t/firebase-data-storing/955078>\
**Category:** Questions about Thunkable X\
**Created:** [November 5, 2020, 11:41pm UTC](https://community.thunkable.com/t/firebase-data-storing/955078 "2020-11-05T23:41:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![maurizio.polverini89](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maurizio.polverini89/32/145191_2.png) [@maurizio.polverini89](https://community.thunkable.com/u/maurizio.polverini89)\
**Post date:** [November 5, 2020, 11:41pm UTC](https://community.thunkable.com/t/firebase-data-storing/955078/1 "2020-11-05T23:41:21Z")

</div>

Hi, im using firebase.  
I want that everytime someone hits a button it saves his name on the realtime database on Firebase under a certain key and certain field.

Tom hit the button of the image 1.

Image 1

- Likes  
— Tom

The problem is when i want to add more people to this list. I tried using a list block, an object block, to save values with variables and databes, but cant make it work.  
I would need that if Mark or whoever in the future also hits that button it says:

Image 1

- Likes  
— Tom  
— Mark

This is the latest i have tried so far, but i have tried many without success.  
 ![aiuto_Thunkable](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/9/490a78bc9c8d55bf7fe916ce9b5c1498774c2623.png)

Thanks for your help

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 6, 2020, 12:21am UTC](https://community.thunkable.com/t/firebase-data-storing/955078/2 "2020-11-06T00:21:28Z")

</div>

for some reason, appending to a list is not so straightforward.

To add to the list, you first need to GET the list, append the item to the list client side, then SAVE the list back to the appropriate key

---

<div class="post-metadata">

**Author:** ![eddie.rebehy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eddie.rebehy/32/67993_2.png) [@eddie.rebehy](https://community.thunkable.com/u/eddie.rebehy)\
**Post date:** [November 6, 2020, 5:24am UTC](https://community.thunkable.com/t/firebase-data-storing/955078/3 "2020-11-06T05:24:41Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/9/292ac2698f386885a82169b2cf2810a1a3488cae.png)

I’m not sure I fully understand your objective but…  
Have you tried playing around with these blocks instead of using the RTDB blocks?

It seems to be working fine for me.

[https://x.thunkable.com/projectPage/5fa4d96389dcc300110ba3ea](https://x.thunkable.com/projectPage/5fa4d96389dcc300110ba3ea)

Add your Firebase credentials in settings and have a look directly at the list being created in the database.

---

<div class="post-metadata">

**Author:** ![maurizio.polverini89](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maurizio.polverini89/32/145191_2.png) [@maurizio.polverini89](https://community.thunkable.com/u/maurizio.polverini89)\
**Post date:** [November 6, 2020, 10:34am UTC](https://community.thunkable.com/t/firebase-data-storing/955078/4 "2020-11-06T10:34:11Z")

</div>

Hi Jared,  
you are right, my fault i attached the wrong picture.  
 ![aiuto_Thunkable](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/5/25f3ba5b96b50e4cb5af304c738d473fbaad87b0.png)  
That was i was doing

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [November 6, 2020, 10:54am UTC](https://community.thunkable.com/t/firebase-data-storing/955078/5 "2020-11-06T10:54:40Z")

</div>

**Short Answer:**  
You need to include the array positions in the key of the SAVE block. Something like the example below. Although I listed zeros (0), you will need to use the length of each list to get the next number in the JSON array. Otherwise you will just keep overwriting the first (zero) entry in each list.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/b/7b04812f74c4fc1aadbe535890dacb636ac459f5.png)

**Long Answer**  
Oh so much good stuff in your question! I am a big fan of JSON and Firebase. Here are a few suggestions:

1. If you are not already familiar with JSON, I just discovered this very helpful article [5. Arrays, Objects, Functions and JSON - Mixu's Node book](http://book.mixu.net/node/ch5.html).
2. Thunkable LISTs are JSON ARRAYs. In Firebase JSON arrays are stored as a numbered list starting with zero.
3. You can store lists as either an array or a list of properties. Using a list of properties makes searching faster and data updates easier, but the order of insertion into the list is lost. Arrays preserve the order, but are more difficult to add/update/delete in Thunkable. Here is an example showing first a list as properties (participants) and then a list as an array (Thread). ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/0/d004fbdec38c37c2634e6890405b991829fda48d.png)
4. Thunkable struggles to update existing JSON structures beyond the first level. Some helper functions can make those updates a lot easier. Here are my SET and GET helper functions. They also take care of the asynchronous issues of Save and Get Firebase blocks. ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/d/8d5c78d3750a5e322bdd2453729d968ff90fff5c.png)
5. Using The Set Cloud Property function, my example above becomes: ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/7/b768f1742a439cdc48c143df95d2e41bf8c4a4d0.png)
6. For your purposes, I don’t think the order of images (vs. the name of the image) or the order of the like (vs. who liked the image) matters. The example below does not use arrays, so no numbering is required. Getting the data out is a littler counter-intuitive, as you need to use the Get Object Properties block to find out who “liked” the image. ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/5/15615d3b9f84f90240fa61c1c960dd129d46e50b.png)

Happy Thunking!

---

<div class="post-metadata">

**Author:** ![maurizio.polverini89](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maurizio.polverini89/32/145191_2.png) [@maurizio.polverini89](https://community.thunkable.com/u/maurizio.polverini89)\
**Post date:** [November 6, 2020, 11:27am UTC](https://community.thunkable.com/t/firebase-data-storing/955078/6 "2020-11-06T11:27:22Z")

</div>

I’m actually really close.  
Just a minimal step is missing.

![aiuto_Thunkable](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/4/c4941e76e292f63b7ebbc908fa88a40fddc7d26a.png)

It works perfectly with a list that already exists, but it doesnt create a new list if cloud-appname doesnt exist on RLDB. The IF “cloud-appname is empty” doesnt seem to work within these blocks.

I have also tried to call RLDB Get value, for example “Ibiza”, but it gives me “undefined” even though there’s such a value “Ibiza” in the database.

![aiuto_Thunkable](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/9/79b67418ab36b09ba7ba0f7a0fb187e51655ca15.png)

Hope you can help.

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [November 6, 2020, 11:37am UTC](https://community.thunkable.com/t/firebase-data-storing/955078/7 "2020-11-06T11:37:49Z")

</div>

You can get the root of the Firebase Tree using //

Use the resulting object to check to see if the property exists:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/5/658adc175401d01fcfa0349740bd0124823cccd6.png)

---

<div class="post-metadata">

**Author:** ![eddie.rebehy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eddie.rebehy/32/67993_2.png) [@eddie.rebehy](https://community.thunkable.com/u/eddie.rebehy)\
**Post date:** [November 6, 2020, 11:42am UTC](https://community.thunkable.com/t/firebase-data-storing/955078/8 "2020-11-06T11:42:22Z")

</div>

I’ll have another look tomorrow but I have never has any success using if is empty. Use if cloud name = null instead to check if a node exists in rtdb.

---

<div class="post-metadata">

**Author:** ![eddie.rebehy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eddie.rebehy/32/67993_2.png) [@eddie.rebehy](https://community.thunkable.com/u/eddie.rebehy)\
**Post date:** [November 7, 2020, 1:09am UTC](https://community.thunkable.com/t/firebase-data-storing/955078/9 "2020-11-07T01:09:16Z")

</div>

I think these work in most situations as well for null/exists checking.

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/3/1369b61696efbae4b3867c863fe31f836edff1e6.png)

---

<div class="post-metadata">

**Author:** ![maurizio.polverini89](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maurizio.polverini89/32/145191_2.png) [@maurizio.polverini89](https://community.thunkable.com/u/maurizio.polverini89)\
**Post date:** [November 7, 2020, 12:01pm UTC](https://community.thunkable.com/t/firebase-data-storing/955078/10 "2020-11-07T12:01:00Z")

</div>

Thank you very much, that was extremely helpful.  
I think i have just completed my app by using your blocks.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 12:21pm UTC](https://community.thunkable.com/t/firebase-data-storing/955078/11 "2024-11-08T12:21:45Z")

</div>


