DynamoDB: Delete Multiple Items in Javascript (Guide w/ Code Examples)

Provided by Rafal Wilinski
To delete multiple items from a DynamoDB table using the JavaScript SDK, you can use the batchWritemethod. This method allows you to delete multiple items in a single call, which can be more efficient than making multiple individual delete calls.
const AWS = require('aws-sdk'); const dynamoDb = new AWS.DynamoDB.DocumentClient(); const tableName = 'myTable'; const itemsToDelete = [ { DeleteRequest: { Key: { id: 'item1', }, }, }, { DeleteRequest: { Key: { id: 'item2', }, }, }, // ... add more items to delete here ]; const params = { RequestItems: { [tableName]: itemsToDelete, }, }; dynamoDb.batchWrite(params, (err, data) => { if (err) { console.error(err); } else { console.log(data); } });
Similar Code Examples
- DynamoDB: Get Multiple Items
- DynamoDB: Get By ID
- DynamoDB: Query Date Range
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Delete Table
- DynamoDB: Increment Counter
- DynamoDB: BatchGetItem
- DynamoDB: Attribute Not Null
- DynamoDB: Query KeyConditionExpression
- DynamoDB: Get Last 10 Records
- DynamoDB: Query Count
- DynamoDB: Bulk Insert
- DynamoDB: Delete All Items With Partition Key
- DynamoDB: Query Group By
- DynamoDB: Query Greater Than
Tired of switching accounts and regions? Use Dynobase.
First 7 days are on us. No strings attached.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase