Dyanmodb.update to delete entry from StringSet does not work
See original GitHub issueConfirm by changing [ ] to [x] below to ensure that it’s a bug:
- I’ve gone though Developer Guide and API reference
- I’ve checked AWS Forums and StackOverflow for answers
- I’ve searched for previous similar issues and didn’t find any solution
Describe the bug Can not delete a entry from string set using DELETE operation.
Is the issue in the browser/Node.js? Node.js
If on Node.js, are you running this on AWS Lambda?
Details of the browser/Node.js version 10.17.0
SDK version number 2.580.0
To Reproduce (observed behavior) Steps to reproduce the behavior (please share code or minimal repo)
- Create StringSet and put some data in it.
- Delete entry from Set (error)
Invalid UpdateExpression: Incorrect operand type for operator or function; operator: DELETE, operand type: MAP"
problem code.
const dynamoDb = new AWS.DynamoDB.DocumentClient();
const resp = await dynamoDb.scan({
TableName: TABLE_NAME,
FilterExpression: 'attribute_exists(Cids)',
}).promise();
console.info(`Update ${resp.Count} users`);
for (const item of resp.Items || []) {
console.info(item.Uid);
await dynamoDb.update({
TableName: TABLE_NAME,
Key: {
Uid: { S: item.Uid },
},
UpdateExpression: 'DELETE Cids :cameraId',
ReturnValues: 'ALL_NEW',
ExpressionAttributeValues: {
':cameraId': { SS: [id] },
}
}).promise();
}
but same operation in python and CLI works.
Expected behavior Delete the entry from string set.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:16 (3 by maintainers)
Top Results From Across the Web
DynamoDb documentClient.update or delete StringSet ...
I successfully update and delete an item from a StringSet in a dynamoDb table when called from my test app running on localhost....
Read more >Update expressions - Amazon DynamoDB
An update expression specifies how UpdateItem will modify the attributes of an item—for example, setting a scalar value or removing elements from a...
Read more >Updating & Deleting Items
The most common update clause is "SET", which is used to add an attribute to an Item if the attribute does not exist...
Read more >[Solved] DynamoDB Update Not Working
There can be many reasons for the update operation to fail. It is probably an error in your UpdateExpression , or you are...
Read more >DynamoDB — Boto3 Docs 1.26.37 documentation
For more information, see Working with Tables in the Amazon DynamoDB ... With languages that don't support threading, you must update or delete...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
DocumentClient.createSet()
works.or
no DocumentClient version works too.
The only workaround possible for me here was not to use a DELETE operation, instead, you gotta query the item, find the index in the array you wish to delete, and remove it a REMOVE operation:
like in this case, arrayField contains an array of Users, and I want to delete by user’s phoneNumber.
const dataStore = await dynamodb.get(queryParams).promise(); let i=0; //save the index for(i = 0; i < dataStore.Item.myTable.length; i++){ if(dataStore.Item.arrayField[i].phone === phoneNumber) { break; } }
//extracted from for loop for clarity
.net dev celerino herrera g https://chamizo.pro/contact
On Fri, Apr 30, 2021 at 1:06 PM Paulo Fagiani @.***> wrote: