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.
The problem is that you are replacing the entire /expenses every time you click to add an expense:
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.
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.