# Help with Firebase Data Overwriting Issue

**URL:** <https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434>\
**Category:** Questions about Thunkable X\
**Tags:** firebase, blocks\
**Created:** [May 10, 2025, 4:25pm UTC](https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434 "2025-05-10T16:25:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![varunkadapatti](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@varunkadapatti](https://community.thunkable.com/u/varunkadapatti)\
**Post date:** [May 10, 2025, 4:25pm UTC](https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434/1 "2025-05-10T16:25:37Z")

</div>

So basically I am building the expenses tracker app and in that basically what the user does is they sign up for an account and anytime they like let’s say buy an item at a store, they open the app and they manually add a transaction.

So basically the problem I am having is that if a user If the user has already added a transaction, let’s say, for a particular date, MAY 9th and now is adding a new transaction on May 10th. What is happening is that it is overwriting ALL the May 9th transaction with May 10th. And I need to know how to fix this to create separate like different, different dates. And within that, the same data structure should be there.

So I am just attaching the pictures of the code and showing you the database structure in firebase.

Thank you very much.  
Warmly,  
Varun Kadapatti

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

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/8/48ab885b86cc36df9c2013de100c7165a1849b9c.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 10, 2025, 10:42pm UTC](https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434/2 "2025-05-10T22:42:55Z")

</div>

The problem is that you are replacing the entire `/expenses` every time you click to add an expense:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/optimized/3X/6/a/6a26844972da5f252b6345c8103ad7e67e22d565_2_690x66.png)

What you need to do is to add an item onto the **end** of `/expenses`. I think if you set cloud variable `app variable sessionemail`/“expenses”/`call date's Get Date` to [some object or value] then it should work fine. You may have to remove special characters from the date value if they don’t work as a Firebase realtime database property name.

You can also ask ChatGPT or another AI how to do this efficiently with Firebase and Thunkable.

---

<div class="post-metadata">

**Author:** ![varunkadapatti](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@varunkadapatti](https://community.thunkable.com/u/varunkadapatti)\
**Post date:** [May 12, 2025, 2:46pm UTC](https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434/3 "2025-05-12T14:46:59Z")

</div>

I feel my logic is correct in this case. The one thing I want to know is how to traverse the data under “expenses”. Is there a way to loop through the records under “expenses” using for loop?  
The way it works is:

Loop through every entry under “expenses” i.e. check every date under “expenses”

if the Entered date matches with a particular date under “expenses”  
then add the transaction unnder that particular date.

But the qn. is how to loop through tthe records?

ChatGPT and gemini were not of much help - they don’t understand precisely what I’m trying to do.

Thanks  
Warmly,  
Varun

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 13, 2025, 4:28am UTC](https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434/4 "2025-05-13T04:28:14Z")

</div>

Can you post the entire JSON response as **text**? Be sure to format it using the \</\> button in the toolbar right above the post.

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

---

<div class="post-metadata">

**Author:** ![varunkadapatti](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@varunkadapatti](https://community.thunkable.com/u/varunkadapatti)\
**Post date:** [May 13, 2025, 5:43pm UTC](https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434/5 "2025-05-13T17:43:30Z")

</div>

Could you please specify for which part of the code i should send the JSON response for?

---

<div class="post-metadata">

**Author:** ![varunkadapatti](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@varunkadapatti](https://community.thunkable.com/u/varunkadapatti)\
**Post date:** [May 14, 2025, 5:29am UTC](https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434/6 "2025-05-14T05:29:07Z")

</div>

Hello, I was able to identify the issue in the code and fix it. Than you very much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [August 12, 2025, 5:29am UTC](https://community.thunkable.com/t/help-with-firebase-data-overwriting-issue/3817434/7 "2025-08-12T05:29:23Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
