Add list to tiny db without deleting previous value

Hi all
How to append list items into tinyDB ,without deleting the previous values
for example when i store to tinyDB a new list of items , tinyDB clears the previous values and add the new list . what happens is that ..
first time i open the app and select an item to save to DB and make a list of it and it goes ok , when i close the app and open it again the list also is ok , but when i add new list items to DB i found the last items i added only appear ,not all items i added

this in screen 1

and the the new items to be saved in screen 2

any help for this ?!

Hi, Moustafa.
You can’t add data to TinyDB ( last data store are there ). But can store TinyDB data into in a variable and add data to variable and last store this into TinyDB. I hope that it should be understood what I mean.

More easy:
If you store on tag “user” the values 1, 2, 3 and next store on the same tag the values 4, 5, 6. When you get TinyDB value of tag “user” you get only 4, 5, 6.

1 Like

Use it like this:

It’s completels untested, so Idk if that works.

Yoshi

1 Like

i think this will work

Alternative way

OR

Well, this way will be better bc of the less kode if it works. But I don’t excoriate you, I thought of yours, too :kissing_heart:

thank you Leandro i got it , thanks for your time :heart_eyes:

thank you yoshi for your time i used it but in the next time i open the app i see that it make a list of all items in the first item (a list in one item) and add the new in second or third so i found the solution with
@WatermelonIce

I see the problem.
As @m0ustafamahm0ud said

If the user continues storing more list, it will make a list in a list in a list in a list… and so on

1 Like

thank you a lot these two methods are the same and and they are greate , first one worked great
the second i needed to change "value If Tag Not There " to create empty list

Oh yes, it is my problem. :slight_smile:

no no no you are the best :heart_eyes:

Thanks :grin:

Btw, because you cannot define a variable as tinyDB GetValue, so you have to set it to an empty list first, then when screen initialize set variable as tinyDB getValue

1 Like

I found that this solution is the same as mine, but @bestprintsf is first, so you may mark his answer as the solution.

1 Like

thanks for both of you

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