Delete item from a list in tinydb (NOT in variable) [doubt]

Hello community, I have a question regarding tinydb .. suppose I create a list in a variable

now I want to remove item 4 from that list, but on top of that I also want this change to remain when I close my app and open it again.
so the correct thing would be to remove item 4 from the variable containing the list and then save it to tinydb?
blocks (2)

or can I somehow do something similar to this?


MY QUESTION IS, can you delete an item from the list directly from tinydb?

my doubt arises from the following...
If I want to delete element 4 from the list and then close the application, when I reopen the application my list in tiny db will have a list with 3 elements stored but my "list" variable will still have 4 elements.
Well, if now I close the application again and open it again and now I want to remove item 3 from the list and I do it this way:
blocks

in tinydb the element 1,2 and 4 will be saved ...
because the list variable always contains the 4 elements when restarting the application and what I wanted was to get elements 1 and 2 this time and save them in tinydb ...

so I ask ... can't I just delete items from the list that are already in tinydb? I can't find a correct way to do this so as not to have problems

Maybe you can try something like this, creating a procedure

If you create a Static List as per your example, that is permanent - if you change it at runtime, it will return to the original values next time the App is run. Note that 'list' should not be the name of any list as it is likely used in App Inventor's underlying code, so always give your Lists a meaningful name e.g. 'List_Greetings'.

Since you need a Dynamic List, best to do that with TinyDb alone.

Dora you really are amazing! I do not know how you do it but whenever I have a question, you understand it perfectly and you know exactly how to help me!

Sorry for responding late, I was adapting this code to my program to see if what I had in mind worked. and works !! I'm doing a little random question game ... and I couldn't get the questions that were answered correctly to be removed from the list.

The following happened to me:
I deleted question 4 (which was correctly answered) and when I left and re-entered the application it showed the list with elements 1,2 and 3 ... but now I deleted question 3 (which was correctly answered) and again I exit and I enter the app, this time it showed me the list with elements 1,2 and 4.

YOUR BLOCKS SOLVED MY PROBLEM! I really appreciate your help dora! ^^ really thank you very much! and I hope this will serve someone else in the future.

PS: I hope to meet you in the next question that I have ^^ :face_with_hand_over_mouth:

1 Like

Glad I could help :slight_smile:

1 Like

Chris Thank you very much for your explanation, I will keep this in mind!