Tinydb - storing and getting value from a list

I want to store multiple values (as a list) in a tag (say ‘categories’). At some point I would also want to get values from tinydb & check if the tag ‘categories’ contains a value called ‘x’. Since the values are stored in a list (‘x’ is one of the values in the list) I’m a bit confused. Could you people help me with it ?
It would be greatly appreciated if you could show me the blocks.

1 Like

@mikkupoocha

You can use This

1 Like

@PRATY_PROGRAMME_S_LABS A lot of numbers to be stored. Any other way without the index thing ? I just wanna check if the list has a certain number. So I hope index is not important. Can this be done with a ‘for each do’ loop ?

Call the list back from the tinydb to a variable and use the “is in list” block to check if an item is in the list

1 Like

@TimAi2
loop Store
This what I tried & is wrong. Could you help me correct this ?
when I add a new value to the list the previously stored one gets deleted.

I am sure this method will solve your problem

what this one has to do with my question ?

No sign of the “is in list” block ???

My question was regarding lists & tinydb. I just don’t understand what you’re trying to say.

where shall I put it ? if you dont mind can you show it with blocks ?

Like so:

image

1 Like

The main problem is when I add new values (via variables) to the list the previous values gets deleted. Like if the list previously had a value ‘1’ then if I add a new value ‘2’ then ‘1’ will get deleted or removed.

Add the new values to a list, then save the list to the tinydb with a tag

image

to retrieve the list and set to a variable:

image

1 Like

did you check my screenshots above ? this is what I did na ?

sharing them again:
loop Store

How is global TinyDB_List variable initialised?

Initialize

You need to set your global TinyDB_List variable to the list stored in TinyDB before adding items to list. Something like this :point_down:




Above is just an example. You have to set it according to your need

7 Likes

Not working. I tried it beofre, But it was placed below ‘call TinyDB1 store value’. Not working this time too.

For me its working exactly as it should work. Can you post a sample aia here illustrating the problem?

there are like 1700+ blocks :no_mouth: