How do you remove data in list in tinydb?

So, hello I'm working on a project where we need to create a Add cart then Buy button, but I encounter a problem in buy

So, I'm trying to do is when player select an item in cart then click buy it would be deleted on the list. but that's not happening.

I'm trying a 2 way but none of them are working.

Here's my blocks

1 Like

It's always the same. You read the list from tinyDB, you remove the item from the list, you store again the list into tinyDB.

In your blocks you are reading data from tinyDB into a local variable "list", adding an element to "list", storing again "list" in tinyDB....and removing an item from "userData" variable....

That's what I's trying to do since I need to remove the list on the cart then save it to the tinydb of Purchase, to display it to purchase.

the tag is different where that player saving the selected list to the where the system trying to remove a list.

Here the blocks where the UserData

Try to debug your lists in each step and use Do it to ensure that the lists are populated and deleted like you want.

Is "Userds" a list? are you using a list like a tag?

The Userds is the list of users the been created through the apps. so it's saving a data with the nametag of the list + username. so it would be connected to each account

This looks worrying, your app seems to be a breeding ground for duplication and repetition...

Yes. lmao sine when im trying to combine then as one it's not working, so I decide to make it one to one' it just to display the items that user add cart. if I combine then as one when user add to cart with different tag it won't display unless the 1st one have a data on it. so that's what i'm end up HAHhaha

So If "Userds" has, for example, three users "user1", "user2" and "user3" you are using the tag:

Carts["user1", "user2", "user3"]

that is what you want?

So i have 2 tag for the username.
Here's how it work.

the username that been created would be saved in 2 tags

1st tags - where all username that been created was saved.
2nd tags- where only 1 data can be saved. this also i'm using when I log in.

So when user log in, the system would check is the username that been save in the 2nd tags was saved in the 1st tag, if it was in there it would display all data that been saved to that username.

so it would go like this


I don't know if this complicated or not but it works HAHha.

Ok. Anyway, what is the list from which you want to remove an item? How do you read it from tinyDB?, how are you deleting the element and how do you save it again?

So, I'm trying to remove an item in list tag "carts", but before removing it i want to save it first to the CheckOut tags. this how it read in tinydb ["Chicken.jpg", "Chicken", "100.00"]

But what do you have in "UserdData"? because the two ways to delete elements that you are using do not make sense....the first way you are removing always the first element of the list...the second way...I don't know what do you want to do...

Can you paste here the content of UserdData after to be read from tinyDB?

Here's the content of the UserdData

No. That is a screenshot of your app. Please, use Do it ( 'Do It' to view procedure results, event arguments and local variables ( and paste here the content of "UserdsData" (and the tag) after reading from tinyDB.

Do It Result: [["Chicken.jpg", "Chicken", "100.00"], ["Beengaling.jpg", "Bee", "100.00"], ["Butterfly.jpg", "Butterfly", "100.00"]]

Try this to remove an item (with the ProductName.Text) from UserdData:

you will need to store again UserdData in tinyDB.

It's not working at all, I don't know why but this should be delete that specific data that been selected by the user in tinydb then store that remove data in the other tinydb but that's not working

Use DO it to check the values of your lists, the tags and so on...

I know now what i did wrong lmao. I didn't save the changes that's why the value is keep coming back even it's already remove

1 Like

I just encounter a problem with this, it's removing all the data in the tinydb not just the chicken, but all of the data save under those tags.