cloudDB delete items from tag

I have in the cloud DB tag that store list value. how can i remove the last value without data lost? like this command but to the first one

Get the list from CloudDB, remove the last item, and store it again.

BUT then data can be lost if two doing it in the same time

1 Like

what do you mean? what are you expecting when two devices try to remove the last item from a list stored in cloudDB? If you are removing last item, which data will be lost?

I have list under tag: hello
list contains: [hi1,hi2,hi3,hi4]
hi1 is first index
I want a button that when you click him it will remove the first index.
like this command but to the first.

In the way you suggested if two will click the button only the hi1 will removed.
you have ideas what can I do?

Obtain the first element of a list and atomically remove it. If two devices use this function simultaneously, one will get the first element and the the other will get the second element, or an error if there is no available element. When the element is available, the FirstRemoved event will be triggered.

Sorry my mistake,
I meant to delete the last item.
like remove first but to the last.
how I can do that?

Check the contents of that List item you want to remove using GetValue(tag,valueIfTagNotThere)
GetValue asks CloudDB to get the value stored under the given tag before you use the Remove block. It will pass the result to the GotValue will be given.

If you are the first user to Remove the item, the item should be removed however a second user's request for the same item content will probably be ignored if the GotValue does not contain the 'contents' both users request to be removed

you are talking when you have 1 item. I talking when you have list with 10 items and two users are trying to remove the last item . so if you have list [0,1,2,3,4,5,6,7,8,9] i want that one user will remove the item 9 and the other user will remove the item 8. but if they both will click remove at the same time they both will remove the item '9' and not the item '8'. so i want command like RemoveFirstFromList but to the last(RemoveLastFromList). How I can do it?

Are you using your own redis server ?

no, I am using app inventor server

This is a hard problem.

The CloudDB list blocks are geared only for using the lists as First In First Out (FIFO) queues.

To get atomic deletion and insertion in order, you will need unique subtags like Clock1.SystemTime, and will need to deal with them one by one.

Ok, sad that there there is not block RemoveLastFromList

quote="yosi, post:13, topic:116323"]
there is not block RemoveLastFromList

This was obvious from the beginning... :upside_down_face: