I Need help with my Firebase and Listview update and delete

Hello! I'm new to MIT

Im trying to make a shoe shopping app where i can input data and with a press of a button, i can add that data to my cart (which is firebase).

When i add new items to my cart, it creates a new OrderNo. in firebase

Example:
New Items created
image

So here's my issue. Whenever i try to update items (without deleting anything) In my cart it will be updated both in listview and firebase. However, when i delete an item and then try to update another item, it updates the firebase not based on the OrderNo. but based on which number is the item on the listview.

Example:
New items created

I deleted 1 item which is OrderNo. 2


Here is the updated firebase:
image

Now i want to update OrderNo.3 and change its price to 700. However when i select the item in ListView, it will read it as OrderNo.2, so when i press the update button it creates a new Item in the database called OrderNo.2 instead of updating OrderNo.3

image

I need to be able to find a way on how to update and delete both items in my ListView and Firebase based on the OrderNo. and not on the selection on the ListView

here is my blocks:

Im kinda new to MIT so any help would be great. Thanks! :slight_smile:

How do you call the data from db to app? Blocks?

To solve your problem I hope you need to use index is in list block while deleting

Index is in list Thing (List view selection) in list (global tag list)

image

Here us how i remove the item from the list

And here's my aia file
TESTDBUPDATE1.aia (5.4 KB)

I would first change the format of your order numbers from Order Number : 1 to something like ON0001.

Then you can more easily use the listview selection to get the order number, so that you can then update the caart against that order number.

If you use order number then you will struck in this kind of situation..

Imagine, there are two tags like order number 1 and 2. You are deleting and trying to add one more item in cart.. what will happen in this situation?

If you count the tag list it will result as 1, then upon try to add another new order item then previous order 2 will be over written infintely. You cannot add the third item. So try some other way.. i have slightly modifed.. test this

TESTDBUPDATE1_1.aia (6.4 KB)