can we delete multiple records in dynamo db only through range key?
I'm trying to do like this sql statement
delete from employee where employee_name='gopal';
so here the records with employee name gopal
should get deleted
can we achieve same like this sql query in dynamo db?
With the DynamoDB API, you use the DeleteItem action to delete data from a table, one item at a time. You must specify the item's primary key values. In addition to DeleteItem , Amazon DynamoDB supports a BatchWriteItem action for deleting multiple items at the same time.
Open the DynamoDB console at https://console.aws.amazon.com/dynamodb/ . In the navigation pane, choose Tables. Choose the Features table. From the Actions menu, choose Delete Table.
Go to your DynamoDB table dashboard. You can navigate there from DynamoDB -> Tables -> YourTable -> Dashboard. Click on the truncate button to truncate your table. You'll see a confirmation dialog asking you to type TRUNCATE to confirm.
You would have to do a BatchWriteItem to delete your items. From the documentation:
BatchWriteItem performs put and delete
Please Check This query it's working with multiple data
const params = {TableName: "test"};
docClient.scan(params, (error, result) => {
if (error) { console.log(error,"error scan"); }
result.Items.forEach(function(item) {
docClient.delete({Key:{mainID: item.id},TableName:"test"}, (error) => {
if (error) {
console.log("Delete fail");
}
console.log("Delete Success");
});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With