Need to remove a list item from a DynamoDb database in a react app using its index.
Going by the example in https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Js.03.html , Update an Item (Conditionally)
The update expression for removing an item is
UpdateExpression: "remove info.actors[0]",
What is the update expression when the index value is a parameter to the function?
The only way to do this is to just build the UpdateExpression
string with the appropriate number in it. As LazyElephant suggested in a comment: "Remove info.actors[" + index + "]"
.
You might think that it should also be possible to write remove info.actors[:i]
where :i
is defined in ExpressionAttributeValues
. But unfortunately, this doesn't work. DynamoDB refuses it as a syntax error. I can't say I understand why.